-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Refine PR Builder Code #5933
Refine PR Builder Code #5933
Changes from 6 commits
763b857
2537fc3
9e643dc
999070b
4f1709e
ce1353e
f84ee69
b1fe82f
8ed0345
290bab8
bf8247f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,30 +105,23 @@ def get_or_create_external_version(project, identifier, verbose_name): | |
:returns: External version. | ||
:rtype: Version | ||
""" | ||
external_version = project.versions( | ||
manager=EXTERNAL | ||
).filter(verbose_name=verbose_name).first() | ||
external_version, created = project.versions.get_or_create( | ||
verbose_name=verbose_name, | ||
type=EXTERNAL, | ||
defaults={'identifier': identifier, 'active': True}, | ||
) | ||
|
||
if external_version: | ||
if not created: | ||
# identifier will change if there is a new commit to the Pull/Merge Request | ||
if external_version.identifier != identifier: | ||
external_version.identifier = identifier | ||
external_version.save() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably log in this case too (eg. updated external version) |
||
else: | ||
# create an external version if the version does not exist. | ||
created_external_version = Version.objects.create( | ||
project=project, | ||
type=EXTERNAL, | ||
identifier=identifier, | ||
verbose_name=verbose_name, | ||
active=True | ||
) | ||
log.info( | ||
'(Create External Version) Added Version: [%s] ', ' '.join( | ||
created_external_version.slug | ||
external_version.slug | ||
) | ||
) | ||
return created_external_version | ||
return external_version | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,11 @@ | |
{% endif %} | ||
</span> | ||
<span class="build-commit" data-bind="visible: commit"> | ||
{% if build.get_commit_url %} | ||
(<a data-bind="attr: {href: commit_url}"><span data-bind="text: commit">{{ build.commit }}</span></a>) | ||
{% else %} | ||
(<span data-bind="text: commit">{{ build.commit }}</span>) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this break the JS code that tries to update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay I'll check this :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have checked. there is no error on the browsers console window. and |
||
{% endif %} | ||
</span> | ||
</div> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd switch this logic around, and do
if created
. It just reads a bit cleaner.