-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Update build list and detail page UX #5916
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
Merged
ericholscher
merged 6 commits into
readthedocs:gsoc-19-pr-builder
from
saadmk11:fix-build-ux
Jul 15, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1167c40
Update build list and detail page
saadmk11 d5af035
added commit url
saadmk11 1dd6bf2
Added commit url for build details page
saadmk11 2166770
Added tests
saadmk11 9af5521
setting commit url updated
saadmk11 8310e58
lint fix
saadmk11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,13 @@ | |
from readthedocs.config import LATEST_CONFIGURATION_VERSION | ||
from readthedocs.core.utils import broadcast | ||
from readthedocs.projects.constants import ( | ||
BITBUCKET_COMMIT_URL, | ||
BITBUCKET_URL, | ||
GITHUB_COMMIT_URL, | ||
GITHUB_URL, | ||
GITHUB_PULL_REQUEST_URL, | ||
GITHUB_PULL_REQUEST_COMMIT_URL, | ||
GITLAB_COMMIT_URL, | ||
GITLAB_URL, | ||
PRIVACY_CHOICES, | ||
PRIVATE, | ||
|
@@ -36,6 +41,8 @@ | |
BUILD_STATE_FINISHED, | ||
BUILD_STATE_TRIGGERED, | ||
BUILD_TYPES, | ||
GENERIC_EXTERNAL_VERSION_NAME, | ||
GITHUB_EXTERNAL_VERSION_NAME, | ||
INTERNAL, | ||
LATEST, | ||
NON_REPOSITORY_VERSIONS, | ||
|
@@ -63,6 +70,7 @@ | |
get_gitlab_username_repo, | ||
) | ||
from readthedocs.builds.version_slug import VersionSlugField | ||
from readthedocs.oauth.models import RemoteRepository | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
@@ -158,9 +166,20 @@ def vcs_url(self): | |
""" | ||
Generate VCS (github, gitlab, bitbucket) URL for this version. | ||
|
||
Branch/Tag Example: https://github.com/rtfd/readthedocs.org/tree/3.4.2/. | ||
Pull/merge Request Example: https://github.com/rtfd/readthedocs.org/pull/9999/. | ||
Example: https://github.com/rtfd/readthedocs.org/tree/3.4.2/. | ||
External Version Example: https://github.com/rtfd/readthedocs.org/pull/99/. | ||
""" | ||
if self.type == EXTERNAL: | ||
if 'github' in self.project.repo: | ||
user, repo = get_github_username_repo(self.project.repo) | ||
return GITHUB_PULL_REQUEST_URL.format( | ||
user=user, | ||
repo=repo, | ||
number=self.verbose_name, | ||
) | ||
# TODO: Add VCS URL for other Git Providers | ||
return '' | ||
|
||
url = '' | ||
if self.slug == STABLE: | ||
slug_url = self.ref | ||
|
@@ -169,25 +188,12 @@ def vcs_url(self): | |
else: | ||
slug_url = self.slug | ||
|
||
if self.type == EXTERNAL: | ||
if 'github' in self.project.repo: | ||
slug_url = self.verbose_name | ||
url = f'/pull/{slug_url}/' | ||
if ('github' in self.project.repo) or ('gitlab' in self.project.repo): | ||
url = f'/tree/{slug_url}/' | ||
|
||
if 'gitlab' in self.project.repo: | ||
slug_url = self.identifier | ||
url = f'/merge_requests/{slug_url}/' | ||
|
||
if 'bitbucket' in self.project.repo: | ||
slug_url = self.identifier | ||
url = f'/pull-requests/{slug_url}' | ||
else: | ||
if ('github' in self.project.repo) or ('gitlab' in self.project.repo): | ||
url = f'/tree/{slug_url}/' | ||
|
||
if 'bitbucket' in self.project.repo: | ||
slug_url = self.identifier | ||
url = f'/src/{slug_url}' | ||
if 'bitbucket' in self.project.repo: | ||
slug_url = self.identifier | ||
url = f'/src/{slug_url}' | ||
|
||
# TODO: improve this replacing | ||
return self.project.repo.replace('git://', 'https://').replace('.git', '') + url | ||
|
@@ -745,6 +751,60 @@ def get_full_url(self): | |
) | ||
return full_url | ||
|
||
def get_commit_url(self): | ||
"""Return the commit URL.""" | ||
repo_url = self.project.repo | ||
if self.is_external: | ||
if 'github' in repo_url: | ||
user, repo = get_github_username_repo(repo_url) | ||
if not user and not repo: | ||
return '' | ||
|
||
repo = repo.rstrip('/') | ||
return GITHUB_PULL_REQUEST_COMMIT_URL.format( | ||
user=user, | ||
repo=repo, | ||
number=self.version.verbose_name, | ||
commit=self.commit | ||
) | ||
# TODO: Add External Version Commit URL for other Git Providers | ||
else: | ||
if 'github' in repo_url: | ||
user, repo = get_github_username_repo(repo_url) | ||
if not user and not repo: | ||
return '' | ||
|
||
repo = repo.rstrip('/') | ||
return GITHUB_COMMIT_URL.format( | ||
user=user, | ||
repo=repo, | ||
commit=self.commit | ||
) | ||
if 'gitlab' in repo_url: | ||
user, repo = get_gitlab_username_repo(repo_url) | ||
if not user and not repo: | ||
return '' | ||
|
||
repo = repo.rstrip('/') | ||
return GITLAB_COMMIT_URL.format( | ||
user=user, | ||
repo=repo, | ||
commit=self.commit | ||
) | ||
if 'bitbucket' in repo_url: | ||
user, repo = get_bitbucket_username_repo(repo_url) | ||
if not user and not repo: | ||
return '' | ||
|
||
repo = repo.rstrip('/') | ||
return BITBUCKET_COMMIT_URL.format( | ||
user=user, | ||
repo=repo, | ||
commit=self.commit | ||
) | ||
|
||
return '' | ||
|
||
@property | ||
def finished(self): | ||
"""Return if build has a finished state.""" | ||
|
@@ -756,6 +816,28 @@ def is_stale(self): | |
mins_ago = timezone.now() - datetime.timedelta(minutes=5) | ||
return self.state == BUILD_STATE_TRIGGERED and self.date < mins_ago | ||
|
||
@property | ||
def is_external(self): | ||
return self.version.type == EXTERNAL | ||
|
||
@property | ||
def external_version_name(self): | ||
if self.is_external: | ||
try: | ||
if self.project.remote_repository.account.provider == 'github': | ||
return GITHUB_EXTERNAL_VERSION_NAME | ||
# TODO: Add External Version Name for other Git Providers | ||
except RemoteRepository.DoesNotExist: | ||
log.info('Remote repository does not exist for %s', self.project) | ||
return GENERIC_EXTERNAL_VERSION_NAME | ||
except Exception: | ||
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 log this exception, otherwise it will hide real issues. What exception are we really trying to catch? |
||
log.exception( | ||
'Unhandled exception raised for %s while getting external_version_name', | ||
self.project | ||
) | ||
return GENERIC_EXTERNAL_VERSION_NAME | ||
return None | ||
|
||
def using_latest_config(self): | ||
return int(self.config.get('version', '1')) == LATEST_CONFIGURATION_VERSION | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 do wonder if we should return
None
here, instead of''
. I don't think it matters too much though.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.
for URL's I think its better to return empty string. as it will show
href=''
nothref=None
in the template.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.
We should not output the link if we don't have an
href
attribute.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.
Merging this, but we should fix it ^^
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.
@ericholscher Updated please see this 763b857