From a97d9f594eb2e284d4a3592a6e987bd152fa1efc Mon Sep 17 00:00:00 2001 From: Simon Westphahl Date: Wed, 10 Aug 2022 09:16:02 +0200 Subject: [PATCH] Set remote URL after config was updated To avoid issues with outdated Github access tokens in the Git config we only update the remote URL on the repo object after the config update was successful. This also adds a missing repo lock when building the repo state. Change-Id: I8e1b5b26f03cb75727d2b2e3c9310214a3eac447 --- zuul/merger/merger.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zuul/merger/merger.py b/zuul/merger/merger.py index c3e20e21b1..34b495fcc3 100644 --- a/zuul/merger/merger.py +++ b/zuul/merger/merger.py @@ -733,10 +733,8 @@ class Repo(object): return log = get_annotated_logger(self.log, zuul_event_id) log.debug("Set remote url to %s", redact_url(url)) + self._git_set_remote_url(self.createRepoObject(zuul_event_id), url) self.remote_url = url - self._git_set_remote_url( - self.createRepoObject(zuul_event_id), - self.remote_url) def mapLine(self, commit, filename, lineno, zuul_event_id=None): repo = self.createRepoObject(zuul_event_id) @@ -1244,11 +1242,13 @@ class Merger(object): item['connection'], item['project'], repo_state, item['ref'], item['newrev']) item = items[-1] - repo = self.getRepo(item['connection'], item['project']) # A list of branch names the last item appears in. item_in_branches = [] if item.get('newrev'): - item_in_branches = repo.contains(item['newrev']) + lock = repo_locks.getRepoLock(item['connection'], item['project']) + with lock: + repo = self.getRepo(item['connection'], item['project']) + item_in_branches = repo.contains(item['newrev']) return (True, repo_state, item_in_branches) def getFiles(self, connection_name, project_name, branch, files, dirs=[]):