Commit 80646a8a authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

fix update_branches

parent 6d0ab091
......@@ -30,4 +30,4 @@ class Command(BaseCommand):
except AttributeError:
logger.warning(f'Project {project} has no master branch')' updating branches for {project}')
project.update_branches(main=False, pull=False)
......@@ -18,10 +18,10 @@ class Command(BaseCommand):'updating licenses')
for data in requests.get(LICENSES).json()['licenses']:
instance, created = License.objects.get_or_create(spdx_id=data['licenseId'], defaults={
'name': data['name'], 'url': data['detailsUrl']})
_, created = License.objects.get_or_create(spdx_id=data['licenseId'],
defaults={'name': data['name'], 'url': data['detailsUrl']})
if created:' creating license {data["name"]}')' created license {data["name"]}')
# for data in requests.get(f'{github.api_url()}/licenses', headers=github.headers()).json():
#' updating license {data["name"]}')
# License.objects.get_or_create(spdx_id=data['spdx_id'],
......@@ -170,7 +170,7 @@ class Project(Links, NamedModel, TimeStampedModel):
return repo
def update_branches(self, main=True):
def update_branches(self, main=True, pull=True):
branches = [b[2:] for b in self.git().git.branch('-a', '--no-color').split('\n')]
if main:
branches = [b for b in branches if b.endswith('master') or b.endswith('devel')]
......@@ -183,14 +183,15 @@ class Project(Links, NamedModel, TimeStampedModel):
branch = branch[8:]
forge, namespace, name = branch.split('/', maxsplit=2)
namespace, _ = Namespace.objects.get_or_create(slug=namespace)
repo, created = Repo.objects.get_or_create(forge__slug=forge, namespace=namespace, project=self,
forge = Forge.objects.get(slug=forge)
repo, created = Repo.objects.get_or_create(forge=forge, namespace=namespace, project=self,
defaults={'name':, 'default_branch': 'master',
'repo_id': 0})
if created:
instance, created = Branch.objects.get_or_create(name=branch, project=self, repo=repo)
if created:
def main_branch(self):
heads = self.git().heads
Supports Markdown
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