Skip to content

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
merged 6 commits into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
48 changes: 22 additions & 26 deletions readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from readthedocs.projects.constants import (
BITBUCKET_URL,
GITHUB_URL,
GITHUB_PULL_REQEST_URL,
GITHUB_PULL_REQEST_COMMIT_URL,
GITHUB_PULL_REQUEST_URL,
GITHUB_PULL_REQUEST_COMMIT_URL,
GITLAB_URL,
PRIVACY_CHOICES,
PRIVATE,
Expand Down Expand Up @@ -162,41 +162,36 @@ 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/99/commits/b630b630
Example: https://github.com/rtfd/readthedocs.org/tree/3.4.2/.
External Version Example: https://github.com/rtfd/readthedocs.org/pull/99/commits/b630b630/.
Copy link
Member

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.

"""
url = ''
if self.slug == STABLE:
slug_url = self.ref
elif self.slug == LATEST:
slug_url = self.project.default_branch or self.project.vcs_repo().fallback_branch
else:
slug_url = self.slug

if self.type == EXTERNAL:
if 'github' in self.project.repo:
user, repo = get_github_username_repo(self.project.repo)
return GITHUB_PULL_REQEST_COMMIT_URL.format(
# Get Github Pull Request Commit URL.
return GITHUB_PULL_REQUEST_COMMIT_URL.format(
user=user,
repo=repo,
number=self.verbose_name,
commit= self.commit_name

)
if 'gitlab' in self.project.repo:
slug_url = self.identifier
url = f'/merge_requests/{slug_url}/'
# TODO: Add VCS ULR for other Git Providers
return ''

if 'bitbucket' in self.project.repo:
slug_url = self.identifier
url = f'/pull-requests/{slug_url}'
url = ''
if self.slug == STABLE:
slug_url = self.ref
elif self.slug == LATEST:
slug_url = self.project.default_branch or self.project.vcs_repo().fallback_branch
else:
if ('github' in self.project.repo) or ('gitlab' in self.project.repo):
url = f'/tree/{slug_url}/'
slug_url = self.slug

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
Expand Down Expand Up @@ -558,11 +553,12 @@ def get_external_version_url(self):
return ''

repo = repo.rstrip('/')
return GITHUB_PULL_REQEST_URL.format(
return GITHUB_PULL_REQUEST_URL.format(
user=user,
repo=repo,
number=self.verbose_name
)
# TODO: Add External Version ULR for other Git Providers
return ''


Expand Down
4 changes: 2 additions & 2 deletions readthedocs/projects/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@
'https://github.com/{user}/{repo}/'
'{action}/{version}{docroot}{path}{source_suffix}'
)
GITHUB_PULL_REQEST_URL = (
GITHUB_PULL_REQUEST_URL = (
'https://github.com/{user}/{repo}/'
'pull/{number}'
)
GITHUB_PULL_REQEST_COMMIT_URL = (
GITHUB_PULL_REQUEST_COMMIT_URL = (
'https://github.com/{user}/{repo}/'
'pull/{number}/commits/{commit}'
)
Expand Down