Improve commits compare. Added tags to autocomplete. Dont look for commits if from & to are empty
This commit is contained in:
parent
49fe8fed11
commit
4cc169d3ca
4 changed files with 33 additions and 16 deletions
|
@ -82,20 +82,24 @@ class Commit
|
|||
end
|
||||
|
||||
def compare(project, from, to)
|
||||
first = project.commit(to.try(:strip))
|
||||
last = project.commit(from.try(:strip))
|
||||
|
||||
result = {
|
||||
commits: [],
|
||||
diffs: [],
|
||||
commit: nil
|
||||
commit: nil,
|
||||
same: false
|
||||
}
|
||||
|
||||
return result unless from && to
|
||||
|
||||
first = project.commit(to.try(:strip))
|
||||
last = project.commit(from.try(:strip))
|
||||
|
||||
if first && last
|
||||
commits = [first, last].sort_by(&:created_at)
|
||||
younger = commits.first
|
||||
older = commits.last
|
||||
|
||||
result[:same] = (younger.id == older.id)
|
||||
result[:commits] = project.repo.commits_between(younger.id, older.id).map {|c| Commit.new(c)}
|
||||
result[:diffs] = project.repo.diff(younger.id, older.id) rescue []
|
||||
result[:commit] = Commit.new(older)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue