Fix a crash if there is no commit to be processed
Change-Id: Ied66b9ab694ac5acad0e1c62077eb28d65076a87 JIRA: OPSAUTO-892
This commit is contained in:
@@ -302,35 +302,41 @@ class ImportUpstream(LogDedentMixin, GitMixin):
|
|||||||
self._set_branch(self.import_branch, self.branch, force=True)
|
self._set_branch(self.import_branch, self.branch, force=True)
|
||||||
|
|
||||||
rebase = RebaseEditor(interactive, repo=self.repo)
|
rebase = RebaseEditor(interactive, repo=self.repo)
|
||||||
first = commit_list[0]
|
if len(commit_list):
|
||||||
|
first = commit_list[0]
|
||||||
|
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"""\
|
"""\
|
||||||
Rebase changes, dropping merges through editor:
|
Rebase changes, dropping merges through editor:
|
||||||
git rebase --onto %s \\
|
git rebase --onto %s \\
|
||||||
%s %s
|
%s %s
|
||||||
""", base, first.parents[0].hexsha, self.import_branch)
|
""", base, first.parents[0].hexsha, self.import_branch)
|
||||||
status, out, err = rebase.run(commit_list,
|
status, out, err = rebase.run(commit_list,
|
||||||
first.parents[0].hexsha, self.import_branch,
|
first.parents[0].hexsha,
|
||||||
onto=base)
|
self.import_branch,
|
||||||
if status:
|
onto=base)
|
||||||
if err and err.startswith("Nothing to do"):
|
if status:
|
||||||
# cancelled by user
|
if err and err.startswith("Nothing to do"):
|
||||||
self.log.notice("Cancelled by user")
|
# cancelled by user
|
||||||
|
self.log.notice("Cancelled by user")
|
||||||
|
return False
|
||||||
|
|
||||||
|
self.log.error("Rebase failed, will need user intervention to "
|
||||||
|
"resolve.")
|
||||||
|
if out:
|
||||||
|
self.log.notice(out)
|
||||||
|
if err:
|
||||||
|
self.log.notice(err)
|
||||||
|
|
||||||
|
# once we support resuming/finishing add a message here to tell
|
||||||
|
# the user to rerun this tool with the appropriate options to
|
||||||
|
# complete
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.log.error("Rebase failed, will need user intervention to "
|
self.log.notice("Successfully applied all locally carried changes")
|
||||||
"resolve.")
|
else:
|
||||||
if out:
|
self.log.warning("Warning, nothing to do: locally carried " +
|
||||||
self.log.notice(out)
|
"changes already rebased onto " + self.upstream)
|
||||||
if err:
|
|
||||||
self.log.notice(err)
|
|
||||||
|
|
||||||
# once we support resuming/finishing add a message here to tell the
|
|
||||||
# user to rerun this tool with the appropriate options to complete
|
|
||||||
return False
|
|
||||||
|
|
||||||
self.log.notice("Successfully applied all locally carried changes")
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def resume(self, args):
|
def resume(self, args):
|
||||||
|
|||||||
Reference in New Issue
Block a user