Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: checkout.py

Issue 25853003: Make checkout.GitCheckout usable from apply_issue (Closed) Base URL: http://src.chromium.org/svn/trunk/tools/depot_tools/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« apply_issue.py ('K') | « apply_issue.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: checkout.py
===================================================================
--- checkout.py (revision 226737)
+++ checkout.py (working copy)
@@ -554,8 +554,6 @@
"""Manages a git checkout."""
def __init__(self, root_dir, project_name, remote_branch, git_url,
commit_user, post_processors=None):
- assert git_url
- assert commit_user
super(GitCheckout, self).__init__(root_dir, project_name, post_processors)
self.git_url = git_url
self.commit_user = commit_user
@@ -565,6 +563,8 @@
self.working_branch = 'working_branch'
# There is no reason to not hardcode origin.
self.remote = 'origin'
+ # There is no reason to not hardcode master.
+ self.master_branch = 'master'
def prepare(self, revision):
"""Resets the git repository in a clean state.
@@ -572,6 +572,7 @@
Checks it out if not present and deletes the working branch.
"""
assert self.remote_branch
+ assert self.git_url
if not os.path.isdir(self.project_path):
# Clone the repo if the directory is not present.
@@ -599,8 +600,9 @@
self._check_call_git(['checkout', '--force', '--quiet', revision])
else:
branches, active = self._branches()
- if active != 'master':
- self._check_call_git(['checkout', '--force', '--quiet', 'master'])
+ if active != self.master_branch:
+ self._check_call_git(
+ ['checkout', '--force', '--quiet', self.master_branch])
self._sync_remote_branch()
if self.working_branch in branches:
@@ -709,13 +711,15 @@
cmd.append('--verbose')
self._check_call_git(cmd)
found_files = self._check_output_git(
- ['diff', '%s/%s' % (self.remote, self.remote_branch),
+ ['diff', '%s/%s' % (self.remote,
+ self.remote_branch or self.master_branch),
'--name-only']).splitlines(False)
assert sorted(patches.filenames) == sorted(found_files), (
sorted(patches.filenames), sorted(found_files))
def commit(self, commit_message, user):
"""Commits, updates the commit message and pushes."""
+ assert self.commit_user
assert isinstance(commit_message, unicode)
current_branch = self._check_output_git(
['rev-parse', '--abbrev-ref', 'HEAD']).strip()
« apply_issue.py ('K') | « apply_issue.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698