summaryrefslogtreecommitdiff
path: root/scripts/cros_mark_as_stable.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cros_mark_as_stable.py')
-rw-r--r--scripts/cros_mark_as_stable.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/scripts/cros_mark_as_stable.py b/scripts/cros_mark_as_stable.py
index 531f652de..4b249538b 100644
--- a/scripts/cros_mark_as_stable.py
+++ b/scripts/cros_mark_as_stable.py
@@ -79,12 +79,8 @@ def CleanStalePackages(srcroot, boards, package_atoms):
# TODO(build): This code needs to be gutted and rebased to cros_build_lib.
def _DoWeHaveLocalCommits(stable_branch, tracking_branch, cwd):
"""Returns true if there are local commits."""
- current_branch = git.GetCurrentBranch(cwd)
-
- if current_branch != stable_branch:
- return False
output = git.RunGit(
- cwd, ['rev-parse', 'HEAD', tracking_branch]).output.split()
+ cwd, ['rev-parse', stable_branch, tracking_branch]).output.split()
return output[0] != output[1]
@@ -108,14 +104,23 @@ def PushChange(stable_branch, tracking_branch, dryrun, cwd):
Raises:
OSError: Error occurred while pushing.
"""
+ if not git.DoesCommitExistInRepo(cwd, stable_branch):
+ logging.debug('No branch created for %s. Exiting', cwd)
+ return
+
if not _DoWeHaveLocalCommits(stable_branch, tracking_branch, cwd):
- logging.info('No work found to push in %s. Exiting', cwd)
+ logging.debug('No work found to push in %s. Exiting', cwd)
return
# For the commit queue, our local branch may contain commits that were
# just tested and pushed during the CommitQueueCompletion stage. Sync
# and rebase our local branch on top of the remote commits.
- remote_ref = git.GetTrackingBranch(cwd, for_push=True)
+ remote_ref = git.GetTrackingBranch(cwd,
+ branch=stable_branch,
+ for_push=True)
+ # SyncPushBranch rebases HEAD onto the updated remote. We need to checkout
+ # stable_branch here in order to update it.
+ git.RunGit(cwd, ['checkout', stable_branch])
git.SyncPushBranch(cwd, remote_ref.remote, remote_ref.ref)
# Check whether any local changes remain after the sync.
@@ -141,7 +146,8 @@ def PushChange(stable_branch, tracking_branch, dryrun, cwd):
'%s..%s' % (remote_ref.ref, stable_branch)]).output
description = '%s\n\n%s' % (GIT_COMMIT_SUBJECT, description)
logging.info('For %s, using description %s', cwd, description)
- git.CreatePushBranch(constants.MERGE_BRANCH, cwd)
+ git.CreatePushBranch(constants.MERGE_BRANCH, cwd,
+ remote_push_branch=remote_ref)
git.RunGit(cwd, ['merge', '--squash', stable_branch])
git.RunGit(cwd, ['commit', '-m', description])
git.RunGit(cwd, ['config', 'push.default', 'tracking'])