-
-
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 4 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 |
---|---|---|
|
@@ -22,6 +22,8 @@ | |
from readthedocs.projects.constants import ( | ||
BITBUCKET_URL, | ||
GITHUB_URL, | ||
GITHUB_PULL_REQUEST_URL, | ||
GITHUB_PULL_REQUEST_COMMIT_URL, | ||
GITLAB_URL, | ||
PRIVACY_CHOICES, | ||
PRIVATE, | ||
|
@@ -36,6 +38,8 @@ | |
BUILD_STATE_FINISHED, | ||
BUILD_STATE_TRIGGERED, | ||
BUILD_TYPES, | ||
GENERIC_EXTERNAL_VERSION_NAME, | ||
GITHUB_EXTERNAL_VERSION_NAME, | ||
INTERNAL, | ||
LATEST, | ||
NON_REPOSITORY_VERSIONS, | ||
|
@@ -158,9 +162,22 @@ 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/commits/b630b630/. | ||
""" | ||
if self.type == EXTERNAL: | ||
if 'github' in self.project.repo: | ||
user, repo = get_github_username_repo(self.project.repo) | ||
# Get Github Pull Request Commit URL. | ||
saadmk11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return GITHUB_PULL_REQUEST_COMMIT_URL.format( | ||
user=user, | ||
repo=repo, | ||
number=self.verbose_name, | ||
commit=self.commit_name | ||
) | ||
# TODO: Add VCS ULR for other Git Providers | ||
saadmk11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return '' | ||
|
||
url = '' | ||
if self.slug == STABLE: | ||
slug_url = self.ref | ||
|
@@ -169,25 +186,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 'gitlab' in self.project.repo: | ||
slug_url = self.identifier | ||
url = f'/merge_requests/{slug_url}/' | ||
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'/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 | ||
|
@@ -539,6 +543,24 @@ def get_bitbucket_url(self, docroot, filename, source_suffix='.rst'): | |
source_suffix=source_suffix, | ||
) | ||
|
||
def get_external_version_url(self): | ||
"""Return a Pull/Merge Request URL.""" | ||
repo_url = self.project.repo | ||
|
||
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_URL.format( | ||
user=user, | ||
repo=repo, | ||
number=self.verbose_name | ||
) | ||
# TODO: Add External Version ULR for other Git Providers | ||
saadmk11 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return '' | ||
|
||
|
||
class APIVersion(Version): | ||
|
||
|
@@ -756,6 +778,20 @@ 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 | ||
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? |
||
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
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
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.
Don't we want this URL to point to the PR still? Otherwise we are changing the meaning of this function based on whether the version is external or internal.
We only want specific commits to link to a commit, not the version itself. We need another function to add a specific URL to the commit I think.