From 968cd30898333e064aaa28aead8da119e6b00b33 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 29 Jul 2020 14:32:11 +0100 Subject: git source plugin: Fix check for remote existence When checking whether a remote exists in the cached git repository, we currently perform a substring match on the output of 'git remote'. This fails when there is an existing remote name that contains the name we're looking for. This was fixed by the rewrite of git fetching in !1808, but that change seems unsuitable for the stable 1.4 branch. Instead, split the command output into a list and check that the remote name is in the list. Closes #1372. --- buildstream/plugins/sources/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildstream/plugins/sources/git.py b/buildstream/plugins/sources/git.py index 495246423..94472bacd 100644 --- a/buildstream/plugins/sources/git.py +++ b/buildstream/plugins/sources/git.py @@ -185,7 +185,7 @@ class GitMirror(SourceFetcher): fail="Failed to retrieve list of remotes in {}".format(self.mirror), cwd=self.mirror ) - if remote_name not in remotes: + if remote_name not in remotes.strip().split(): self.source.call( [self.source.host_git, 'remote', 'add', remote_name, url], fail="Failed to add remote {} with url {}".format(remote_name, url), -- cgit v1.2.1