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

Navigate to correct repository for inline comment GitHub link where fork repository is open. #1420

Merged
merged 7 commits into from Mar 5, 2018

Conversation

@grokys
Copy link
Contributor

@grokys grokys commented Jan 17, 2018

When a fork repository was open in VS, but the PRs for the parent repository were being viewed, clicking on the "date" link in an inline comment to go to the comment online was navigating to the fork repository instead of the parent repository.

To fix this, use the correct repository owner for GitHub link in InlineCommentThreadViewModel.GetCommentUrl. An optional owner parameter was added to UriString.ToRepositoryUrl. which will change the owner of the produced repository URL.

Fixes #1413

grokys added 2 commits Jan 17, 2018
We sometimes want to get the URL of a parent or fork repository. Add an optional `owner` parameter to `UriString.ToRepositoryUrl` which will change the owner of the produced repository URL.
@grokys grokys requested review from shana and jcansdale Jan 17, 2018
Meaghan Lewis
var nameWithOwner = owner == null || NameWithOwner == null ?
NameWithOwner :
string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, RepositoryName);

This comment has been minimized.

@shana

shana Jan 29, 2018
Collaborator

Nit: Given owner = null and NameWithOwner != null, won't this mean that nameWithOwner will be /bar instead of bar? I know it probably doesn't make a difference if the Path in UriBuilderstarts with a/`, it will probably get ignored, but wouldn't this be more straightforward as:

var nameWithOwner = owner != null ? string.Format(CultureInfo.InvariantCulture, "{0}/{1}", owner, RepositoryName) : NameWithOwner;

Also, if RepositoryName is null (it can be), should this probably return null even if owner is passed in, for consistency?

@grokys
Copy link
Contributor Author

@grokys grokys commented Feb 14, 2018

@shana I've updated the code with a few more tests and a fix.

Nit: Given owner = null and NameWithOwner != null, won't this mean that nameWithOwner will be /bar instead of bar?

Did you mean the parameter owner here or the property Owner? If you mean the parameter then it would work, unless I'm misunderstanding. If you meant the Owner property then that can't be null if NameWithOwner != null.

Also, if RepositoryName is null (it can be), should this probably return null even if owner is passed in, for consistency?

RepositoryName gets taken before owner, so if there's an owner there's a repository name.

Copy link
Collaborator

@jcansdale jcansdale left a comment

I've tested this against the original repro and it works great. 👍

@shana
shana approved these changes Mar 5, 2018
@shana shana merged commit 9c045e9 into master Mar 5, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@shana shana deleted the fixes/1413-wrong-comment-link branch Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.