Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent commit message on signoffs page #535

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions main/fixtures/repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
"testing": true
}
},
{
"pk": 15,
"model": "main.repo",
"fields": {
"bugs_category": 33,
"staging": true,
"name": "Extra-Staging",
"bugs_project": 5,
"svn_root": "packages",
"testing": false
}
},
{
"pk": 1,
"model": "main.repo",
Expand Down Expand Up @@ -118,5 +130,17 @@
"svn_root": "packages",
"testing": true
}
},
{
"pk": 16,
"model": "main.repo",
"fields": {
"bugs_category": 10,
"staging": true,
"name": "Core-Staging",
"bugs_project": 1,
"svn_root": "packages",
"testing": false
}
}
]
10 changes: 7 additions & 3 deletions packages/management/commands/populate_signoffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create_specification(package, log, finder):
return spec


def get_last_log(repo, pkgbase):
def get_tag_info(repo, pkgbase, version):
# Gitlab requires the path to the gitlab repo to be html encoded and project name encoded in a different special way
pkgrepo = urllib.parse.quote_plus(f'{settings.GITLAB_PACKAGE_REPO}/') + gitlab_project_name_to_path(pkgbase)
url = f'https://{settings.GITLAB_INSTANCE}/api/v4/projects/{pkgrepo}/repository/tags'
Expand All @@ -65,8 +65,12 @@ def get_last_log(repo, pkgbase):
return None

tags = r.json()

# filter out unrelated tags
tags = [tag for tag in tags if tag["name"] == version]

if len(tags) == 0:
logger.error("No tags found for pkgbase %s (%s)", pkgbase, repo)
logger.error("No tags found for pkgbase %s (%s) version %s", pkgbase, repo, version)
return None

tag = tags[0]
Expand All @@ -89,7 +93,7 @@ def add_signoff_comments():
if not group.default_spec:
continue

log = get_last_log(group.repo, group.pkgbase)
log = get_tag_info(group.repo, group.pkgbase, group.version)
if log is None:
continue

Expand Down
8 changes: 4 additions & 4 deletions packages/tests/test_populate_signoffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ def tearDown(self):
self.package.delete()

def test_basic(self):
with mock.patch('packages.management.commands.populate_signoffs.get_last_log') as get_last_log:
with mock.patch('packages.management.commands.populate_signoffs.get_tag_info') as get_tag_info:
comment = 'upgpkg: 0.1-1: rebuild'
get_last_log.return_value = {'message': f'{comment}\n', 'author': '[email protected]'}
get_tag_info.return_value = {'message': f'{comment}\n', 'author': '[email protected]'}
call_command('populate_signoffs')

signoff_spec = SignoffSpecification.objects.first()
assert signoff_spec.comments == comment
assert signoff_spec.pkgbase == self.package.pkgbase

def test_invalid(self):
with mock.patch('packages.management.commands.populate_signoffs.get_last_log') as get_last_log:
get_last_log.return_value = None
with mock.patch('packages.management.commands.populate_signoffs.get_tag_info') as get_tag_info:
get_tag_info.return_value = None
call_command('populate_signoffs')

assert SignoffSpecification.objects.count() == 0
Loading