Skip to content

Conversation

Jaxwood
Copy link
Contributor

@Jaxwood Jaxwood commented Jan 24, 2018

The default VSTS clone url is different from other project repository urls

Default repository url: https://gitopen.visualstudio.com/_git/Project
Sibling repository url: https://gitopen.visualstudio.com/Project/_git/Repository

Trying to use git open -i on the default repository will lead to an
url formatted as https://gitopen.visualstudio.com/_git/Project/_workitems?id=xx
This url is malformed as the _git part should not be part of it.

This change will fix this bug and correctly format url as
https://gitopen.visualstudio.com/Project/_workitems?id=xx

The default VSTS clone url is different from other project repository urls

e.g. Default repository url: https://gitopen.visualstudio.com/_git/Project
     Sibling repository url: https://gitopen.visualstudio.com/Project/_git/Repository

     Trying to use git open -i on the default repository will lead to an
     url formatted as https://gitopen.visualstudio.com/_git/Project/_workitems?id=xx
     This url is malformed as the _git part should not be part of it.

     This change will fix this bug and correctly format url as
     https://gitopen.visualstudio.com/Project/_workitems?id=xx.
@derimagia
Copy link
Collaborator

@ethomson If you have a second can you confirm this?

@Jaxwood
Copy link
Contributor Author

Jaxwood commented Jan 29, 2018

@ethomson could you review it?

@ethomson
Copy link
Contributor

Thanks for the ping. This looks like an accurate assessment of the problem to me. 👍

@Jaxwood
Copy link
Contributor Author

Jaxwood commented Jan 30, 2018

@derimagia not sure if you have seen @ethomson comment above?

@derimagia
Copy link
Collaborator

Hm looking at the code for this specifically your line does what the above line should have done. The issue is it trims the "/_git*" off the end of the url but the beginning slash doesn't exist so it doesn't do anything besides append the _workitems string to it.

Can you combine this and the above line? Something like urlpath="${urlpath/_git\//}/_workitems"

@Jaxwood
Copy link
Contributor Author

Jaxwood commented Jan 31, 2018

@derimagia I tried to make the change you suggested - however it seems like it is not working as one of the testcases for issues is failing.

@derimagia
Copy link
Collaborator

@test "vsts: issue" {
  git remote set-url origin "http://tfs.example.com:8080/Project/Folder/_git/Repository"
  git checkout -B "bugfix-36"
  run ../git-open "--issue"
  assert_output "http://tfs.example.com:8080/Project/Folder/_workitems?id=36"
}

@test "vsts: issue, default project repository" {
  git remote set-url origin "https://gitopen.visualstudio.com/_git/Project"
  git checkout -B "bugfix-36"
  run ../git-open "--issue"
  assert_output "https://gitopen.visualstudio.com/Project/_workitems?id=36"
}

@ethomson First one was there before, second one is from this. Only difference I see is it's in the folder so it has a prefix to the urlpath. Question is - are they both correct? Top one is removing everything after the _git while the bottom one doesn't and shifts it around.

@Jaxwood
Copy link
Contributor Author

Jaxwood commented Feb 10, 2018

@ethomson if you have the time I would appreciate if you could look at what @derimagia wrote above

@ethomson
Copy link
Contributor

They’re both correct. VSTS has a concept of a “project”, which is a unit of team management. A project can have one or more Git repositories. The top form is canonical, specifying some repository in the project, explicitly. The latter is shorthand for the default repository. The work item link appears to be constructed correctly

@Jaxwood
Copy link
Contributor Author

Jaxwood commented Feb 19, 2018

@derimagia did you see the update from @ethomson ?

@derimagia
Copy link
Collaborator

Can you switch the second line to:

urlpath="${urlpath#_git\/*}"

Which will remove the first "_git" argument found in the path. The first line removes /_git/* from the url as long as it's not the first item in the path so these together seem to work. If you can make a quick comment about taking care of both cases then we should be good to go.

@Jaxwood
Copy link
Contributor Author

Jaxwood commented Feb 20, 2018

@derimagia thank you for taking the time to look into this. Please see my latest update.

@derimagia derimagia merged commit d049d44 into paulirish:master Feb 22, 2018
iblea pushed a commit to iblea/git-open that referenced this pull request Jun 17, 2024
Fix bug with open -i on default VSTS project repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants