diff --git a/git_aggregator/repo.py b/git_aggregator/repo.py index 4f32c58..df05370 100644 --- a/git_aggregator/repo.py +++ b/git_aggregator/repo.py @@ -155,11 +155,13 @@ def query_remote(self, remote, refs=None): for ref in refs: yield None, ref, ref return - for sha, fullref in (l.split() for l in out.splitlines()): + for sha, fullref in (line.split() for line in out.splitlines()): if fullref.startswith('refs/heads/'): - yield 'branch', fullref, sha + ref = fullref.split("/")[-1] + yield 'branch', ref, sha elif fullref.startswith('refs/tags/'): - yield 'tag', fullref, sha + ref = fullref.split("/")[-1] + yield 'tag', ref, sha elif fullref == 'HEAD': yield 'HEAD', fullref, sha else: @@ -255,7 +257,7 @@ def init_repository(self, target_dir): # repository cmd += ('--filter=blob:none',) # Try to clone target branch, if it exists - rtype, _sha = self.query_remote_ref(repository, branch) + rtype, _ref, _sha = list(self.query_remote(repository, branch))[0] if rtype in {'branch', 'tag'}: cmd += ('-b', branch) # Emtpy fetch options to use global default for 1st clone @@ -342,7 +344,10 @@ def push(self): "Cannot push %s, no target remote configured" % branch ) logger.info("Push %s to %s", branch, remote) - self.log_call(['git', 'push', '-f', remote, "HEAD:%s" % branch], cwd=self.cwd) + self.log_call( + ['git', 'push', '-f', remote, "HEAD:%s" % branch], + cwd=self.cwd + ) def _check_status(self): """Check repo status and except if dirty.""" @@ -392,8 +397,7 @@ def _execute_shell_command_after(self): self.log_call(cmd, shell=True, cwd=self.cwd) def _merge(self, merge): - logger.info("Merge %s, %s", merge["remote"], merge["ref"]) - cmd = ("git", "merge") + cmd = ("git", "merge", "--ff") if self.git_version >= (1, 7, 10): # --edit and --no-edit appear with Git 1.7.10 # see Documentation/RelNotes/1.7.10.txt of Git diff --git a/tests/test_repo.py b/tests/test_repo.py index 4ed9c49..d42ef50 100644 --- a/tests/test_repo.py +++ b/tests/test_repo.py @@ -95,7 +95,8 @@ def setUp(self): subprocess.check_call(['git', 'tag', 'tag1'], cwd=self.remote1) self.commit_2_sha = git_write_commit( self.remote1, 'tracked', "last", msg="last commit") - subprocess.check_call(['git', 'tag', '-am', 'foo', 'tag2'], cwd=self.remote1) + subprocess.check_call(['git', 'tag', '-am', 'foo', 'tag2'], + cwd=self.remote1) self.commit_3_sha = git_write_commit( self.remote2, 'tracked2', "remote2", msg="new commit") subprocess.check_call(['git', 'checkout', '-b', 'b2'], @@ -171,7 +172,7 @@ def test_simple_merge(self): self.assertTrue(sha) def test_simple_merge_2(self): - ## Launched from an existing git repository + # Launched from an existing git repository remotes = [{ 'name': 'r1', 'url': self.url_remote1