Commit f141cd9e authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

prefer slug in get_or_create

parent 1c589ede
......@@ -177,7 +177,7 @@ class Project(Links, NamedModel, TimeStampedModel):
for branch in branches:'update branch {branch}')
if branch in MAIN_BRANCHES:
instance, created = Branch.objects.get_or_create(name=branch, project=self)
instance, bcreated = Branch.objects.get_or_create(name=branch, project=self)
if branch.startswith('remotes/'):
branch = branch[8:]
......@@ -189,8 +189,8 @@ class Project(Links, NamedModel, TimeStampedModel):
'repo_id': 0})
if created:
instance, created = Branch.objects.get_or_create(name=branch, project=self, repo=repo)
if created:
instance, bcreated = Branch.objects.get_or_create(name=branch, project=self, repo=repo)
if bcreated:
def main_branch(self):
......@@ -599,7 +599,8 @@ def get_default_forge(project):
def update_gitlab(forge, data):'update {data["name"]} from {forge}')
project, created = Project.objects.get_or_create(name=data['name'], defaults={'main_forge': forge})
namespace, _ = Namespace.objects.get_or_create(name=data['namespace']['name'])
namespace, _ = Namespace.objects.get_or_create(slug=data['namespace']['path'],
defaults={'name': data['namespace']['name']})
repo, _ = Repo.objects.get_or_create(forge=forge, namespace=namespace, project=project,
defaults={'repo_id': data['id'], 'name': data['name'],
'url': data['web_url']})
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