refactoring project, commits controllers
This commit is contained in:
parent
dab072c1ab
commit
d730e3ef8b
4 changed files with 63 additions and 45 deletions
|
@ -9,16 +9,54 @@ class Repository
|
|||
@project = project
|
||||
end
|
||||
|
||||
def path
|
||||
@path ||= project.path
|
||||
end
|
||||
|
||||
def project_id
|
||||
project.id
|
||||
end
|
||||
|
||||
def repo
|
||||
@repo ||= Grit::Repo.new(project.path_to_repo)
|
||||
end
|
||||
|
||||
def url_to_repo
|
||||
"#{GITOSIS["git_user"]}@#{GITOSIS["host"]}:#{path}.git"
|
||||
end
|
||||
|
||||
def path_to_repo
|
||||
GITOSIS["base_path"] + path + ".git"
|
||||
end
|
||||
|
||||
def update_gitosis_project
|
||||
Gitosis.new.configure do |c|
|
||||
c.update_project(path, project.gitosis_writers)
|
||||
end
|
||||
end
|
||||
|
||||
def destroy_gitosis_project
|
||||
Gitosis.new.configure do |c|
|
||||
c.destroy_project(@project)
|
||||
end
|
||||
end
|
||||
|
||||
def repo_exists?
|
||||
repo rescue false
|
||||
end
|
||||
|
||||
def tags
|
||||
repo.tags.map(&:name).sort.reverse
|
||||
end
|
||||
|
||||
def repo_exists?
|
||||
repo rescue false
|
||||
def heads
|
||||
@heads ||= repo.heads
|
||||
end
|
||||
|
||||
def tree(fcommit, path = nil)
|
||||
fcommit = commit if fcommit == :head
|
||||
tree = fcommit.tree
|
||||
path ? (tree / path) : tree
|
||||
end
|
||||
|
||||
def commit(commit_id = nil)
|
||||
|
@ -29,12 +67,6 @@ class Repository
|
|||
end
|
||||
end
|
||||
|
||||
def tree(fcommit, path = nil)
|
||||
fcommit = commit if fcommit == :head
|
||||
tree = fcommit.tree
|
||||
path ? (tree / path) : tree
|
||||
end
|
||||
|
||||
def fresh_commits(n = 10)
|
||||
commits = heads.map do |h|
|
||||
repo.commits(h.name, n)
|
||||
|
@ -47,10 +79,6 @@ class Repository
|
|||
commits[0...n]
|
||||
end
|
||||
|
||||
def heads
|
||||
@heads ||= repo.heads
|
||||
end
|
||||
|
||||
def commits_since(date)
|
||||
commits = heads.map do |h|
|
||||
repo.log(h.name, nil, :since => date)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue