diff --git a/git-open b/git-open index cdb5426..e6f8463 100755 --- a/git-open +++ b/git-open @@ -131,9 +131,15 @@ elif [[ ${pathargs[0]} == 'scm' ]]; then IFS='/' urlpath="${pathargs[*]}" providerBranchRef="/browse?at=$branch" elif [[ "${#pathargs[@]}" -ge '2' && ${pathargs[${#pathargs[@]} - 2]} == '_git' ]]; then - # Visual Studio Team Services and Team Foundation Server: keep the - # Team Project and repository name, append branch selector. - providerBranchRef="?version=GB$branch" + # Visual Studio Team Services and Team Foundation Server always have /_git/ as the second to last segment in the url path + if (( is_issue )); then + # Switch to workitems, provide work item id if specified + urlpath="${urlpath%%/_git/*}/_workitems" + providerBranchRef="?id=${branch//[^0-9]/}" + else + # Keep project and repository name, append branch selector. + providerBranchRef="?version=GB$branch" + fi fi openurl="$protocol://$domain/$urlpath" diff --git a/test/git-open.bats b/test/git-open.bats index c1a5575..c3abd6c 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -356,6 +356,13 @@ setup() { assert_output "http://tfs.example.com:8080/Project/Folder/_git/Repository?version=GBmybranch" } +@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" +} + teardown() { cd ..