Commit 1391ce20 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

fix fetch

parent 80646a8a
...@@ -340,13 +340,13 @@ class Repo(TimeStampedModel): ...@@ -340,13 +340,13 @@ class Repo(TimeStampedModel):
return git_repo.create_remote(remote, self.get_clone_url()) return git_repo.create_remote(remote, self.get_clone_url())
def fetch(self): def fetch(self):
git = self.git() git_repo = self.git()
logger.info(f'fetching {self.forge} - {self.namespace}') logger.debug(f'fetching {self.forge} / {self.namespace} / {self.project}')
try: try:
git.fetch() git_repo.fetch()
except git.exc.GitCommandError: except git.exc.GitCommandError:
logger.warning(f'fetching {self.forge} - {self.namespace} - SECOND TRY') logger.warning(f'fetching {self.forge} / {self.namespace} / {self.project} - SECOND TRY')
git.fetch() git_repo.fetch()
def main_branch(self): def main_branch(self):
return self.project.branch_set.get(name=f'{self.git_remote()}/{self.default_branch}') return self.project.branch_set.get(name=f'{self.git_remote()}/{self.default_branch}')
...@@ -449,9 +449,9 @@ class Branch(TimeStampedModel): ...@@ -449,9 +449,9 @@ class Branch(TimeStampedModel):
def update(self, pull=True): def update(self, pull=True):
if pull: if pull:
self.project.main_repo().fetch() self.repo.fetch()
if self.name not in MAIN_BRANCHES: if self.repo != self.project.main_repo():
self.repo.fetch() self.project.main_repo().fetch()
main_branch = self.project.main_branch() main_branch = self.project.main_branch()
if main_branch is not None: if main_branch is not None:
self.ahead = self.get_ahead(main_branch) self.ahead = self.get_ahead(main_branch)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment