diff options
Diffstat (limited to 'Tools/Scripts/webkitpy/common/checkout/scm/git.py')
-rw-r--r-- | Tools/Scripts/webkitpy/common/checkout/scm/git.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/Tools/Scripts/webkitpy/common/checkout/scm/git.py b/Tools/Scripts/webkitpy/common/checkout/scm/git.py index 7c5d80cc3..c7dbd7ca1 100644 --- a/Tools/Scripts/webkitpy/common/checkout/scm/git.py +++ b/Tools/Scripts/webkitpy/common/checkout/scm/git.py @@ -170,11 +170,28 @@ class Git(SCM, SVNRepository): return_code = self.run(["git", "show", "HEAD:%s" % path], return_exit_code=True, decode_output=False) return return_code != self.ERROR_FILE_IS_MISSING + def _branch_from_ref(self, ref): + return ref.replace('refs/heads/', '') + + def _current_branch(self): + return self._branch_from_ref(self.run(['git', 'symbolic-ref', '-q', 'HEAD'], cwd=self.checkout_root).strip()) + + def _upstream_branch(self): + current_branch = self._current_branch() + return self._branch_from_ref(self.read_git_config('branch.%s.merge' % current_branch, cwd=self.checkout_root).strip()) + def merge_base(self, git_commit): if git_commit: - # Special-case HEAD.. to mean working-copy changes only. - if git_commit.upper() == 'HEAD..': - return 'HEAD' + # Rewrite UPSTREAM to the upstream branch + if 'UPSTREAM' in git_commit: + upstream = self._upstream_branch() + if not upstream: + raise ScriptError(message='No upstream/tracking branch set.') + git_commit = git_commit.replace('UPSTREAM', upstream) + + # Special-case <refname>.. to include working copy changes, e.g., 'HEAD....' shows only the diffs from HEAD. + if git_commit.endswith('....'): + return git_commit[:-4] if '..' not in git_commit: git_commit = git_commit + "^.." + git_commit @@ -350,8 +367,7 @@ class Git(SCM, SVNRepository): return self.push_local_commits_to_server(username=username, password=password) def _commit_on_branch(self, message, git_commit, username=None, password=None): - branch_ref = self.run(['git', 'symbolic-ref', 'HEAD']).strip() - branch_name = branch_ref.replace('refs/heads/', '') + branch_name = self._current_branch() commit_ids = self.commit_ids_from_commitish_arguments([git_commit]) # We want to squash all this branch's commits into one commit with the proper description. |