diff --git a/apply_issue.py b/apply_issue.py index 5b1807266e..5a8f7b6eaf 100755 --- a/apply_issue.py +++ b/apply_issue.py @@ -144,7 +144,7 @@ def main(): if scm_type == 'svn': scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) elif scm_type == 'git': - scm_obj = checkout.GitCheckout(full_dir, None, None) + scm_obj = checkout.GitCheckout(full_dir, None, None, None, None) elif scm_type == None: scm_obj = checkout.RawCheckout(full_dir, None, None) else: diff --git a/checkout.py b/checkout.py index 97a193f9cc..450b37973c 100644 --- a/checkout.py +++ b/checkout.py @@ -554,8 +554,6 @@ class GitCheckout(CheckoutBase): """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 @@ class GitCheckout(CheckoutBase): 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 @@ class GitCheckout(CheckoutBase): 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 @@ class GitCheckout(CheckoutBase): 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 @@ class GitCheckout(CheckoutBase): 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()