Merge "Ask rev-parse for shortest unique SHA1"
This commit is contained in:
commit
0c37b02c2e
|
@ -94,6 +94,10 @@ class GitUpstreamCompatCommit(Commit):
|
||||||
def hexsha(self):
|
def hexsha(self):
|
||||||
return self.id
|
return self.id
|
||||||
|
|
||||||
|
@property
|
||||||
|
def short(self):
|
||||||
|
return self.repo.git.rev_parse(self.hexsha, short=True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def iter_items(cls, repo, ref, path='', **kwargs):
|
def iter_items(cls, repo, ref, path='', **kwargs):
|
||||||
"""
|
"""
|
||||||
|
@ -113,3 +117,5 @@ if not hasattr(Commit, 'iter_items'):
|
||||||
Commit = GitUpstreamCompatCommit
|
Commit = GitUpstreamCompatCommit
|
||||||
# monkey patch class so that Repo will use the patched class
|
# monkey patch class so that Repo will use the patched class
|
||||||
git.commit.Commit = GitUpstreamCompatCommit
|
git.commit.Commit = GitUpstreamCompatCommit
|
||||||
|
else:
|
||||||
|
Commit.short = GitUpstreamCompatCommit.short
|
||||||
|
|
|
@ -82,34 +82,27 @@ class RebaseEditor(GitMixin, LogDedentMixin):
|
||||||
with codecs.open(todo_file, "w", "utf-8") as todo:
|
with codecs.open(todo_file, "w", "utf-8") as todo:
|
||||||
for commit in commits:
|
for commit in commits:
|
||||||
if not root:
|
if not root:
|
||||||
root = commit.parents[0].hexsha
|
root = commit.parents[0]
|
||||||
subject = commit.message.splitlines()[0]
|
subject = commit.message.splitlines()[0]
|
||||||
todo.write("pick %s %s\n" % (commit.hexsha[:7], subject))
|
todo.write("pick %s %s\n" % (self._shorten(commit), subject))
|
||||||
|
|
||||||
# if root isn't set at this point, then there were no commits
|
# if root isn't set at this point, then there were no commits
|
||||||
if not root:
|
if not root:
|
||||||
todo.write("noop\n")
|
todo.write("noop\n")
|
||||||
|
|
||||||
todo.write(TODO_EPILOGUE %
|
todo.write(TODO_EPILOGUE %
|
||||||
{'shortrevisions': self._short_revisions(root,
|
{'shortrevisions': "%s..%s" % (self._shorten(root),
|
||||||
commit.hexsha),
|
self._shorten(commit)),
|
||||||
'shortonto': self._short_onto(onto or root)})
|
'shortonto': self._shorten(onto or root)})
|
||||||
|
|
||||||
return todo_file
|
return todo_file
|
||||||
|
|
||||||
def _short_revisions(self, root, commit):
|
def _shorten(self, commit):
|
||||||
|
|
||||||
if not root:
|
if not commit:
|
||||||
return "<none>"
|
return "<none>"
|
||||||
|
|
||||||
return "%s..%s" % (root[:7], commit[:7])
|
return self.git.rev_parse(commit, short=True)
|
||||||
|
|
||||||
def _short_onto(self, onto):
|
|
||||||
|
|
||||||
if not onto:
|
|
||||||
return "<none>"
|
|
||||||
|
|
||||||
return self.git.rev_parse(onto)[:7]
|
|
||||||
|
|
||||||
def _set_editor(self, editor):
|
def _set_editor(self, editor):
|
||||||
|
|
||||||
|
|
|
@ -569,7 +569,7 @@ class SupersededCommitFilter(LogDedentMixin, GitMixin, CommitFilter):
|
||||||
because the following superseding change-ids have not been
|
because the following superseding change-ids have not been
|
||||||
found:
|
found:
|
||||||
%s
|
%s
|
||||||
""", commit.hexsha[:7], commit.message.splitlines()[0],
|
""", commit.short, commit.message.splitlines()[0],
|
||||||
'\n '.join(superseding_change_ids))
|
'\n '.join(superseding_change_ids))
|
||||||
yield commit
|
yield commit
|
||||||
continue
|
continue
|
||||||
|
@ -580,7 +580,7 @@ class SupersededCommitFilter(LogDedentMixin, GitMixin, CommitFilter):
|
||||||
because it has been marked as superseded by the following
|
because it has been marked as superseded by the following
|
||||||
note:
|
note:
|
||||||
%s
|
%s
|
||||||
""", commit.hexsha[:7], commit.message.splitlines()[0],
|
""", commit.short, commit.message.splitlines()[0],
|
||||||
commit_note)
|
commit_note)
|
||||||
|
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
|
||||||
Including change missing 'Change-Id'
|
Including change missing 'Change-Id'
|
||||||
Commit: %s %s
|
Commit: %s %s
|
||||||
Message: %s
|
Message: %s
|
||||||
""", commit.hexsha[:7], commit.message.splitlines()[0],
|
""", commit.short, commit.message.splitlines()[0],
|
||||||
commit.message)
|
commit.message)
|
||||||
yield commit
|
yield commit
|
||||||
continue
|
continue
|
||||||
|
@ -735,7 +735,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
|
||||||
Skipping duplicate Change-Id in search ref
|
Skipping duplicate Change-Id in search ref
|
||||||
%s
|
%s
|
||||||
Commit: %s %s
|
Commit: %s %s
|
||||||
""", change_id, commit.hexsha[:7],
|
""", change_id, commit.short,
|
||||||
commit.message.splitlines()[0])
|
commit.message.splitlines()[0])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -745,7 +745,7 @@ class DiscardDuplicateGerritChangeId(LogDedentMixin, GitMixin, CommitFilter):
|
||||||
Including unmatched change
|
Including unmatched change
|
||||||
%s
|
%s
|
||||||
Commit: %s %s
|
Commit: %s %s
|
||||||
""", change_id, commit.hexsha[:7],
|
""", change_id, commit.short,
|
||||||
commit.message.splitlines()[0])
|
commit.message.splitlines()[0])
|
||||||
yield commit
|
yield commit
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue