Issues for Visual Studio Team Services

Provide issue support for VSTS and TFS, modifying the URL from the
`_git` endpoint to the `_workitems` endpoint and appending the `id`
query string.
This commit is contained in:
Edward Thomson 2017-07-26 18:27:28 +01:00
parent 7642ca2970
commit a3cf0d02fb
2 changed files with 16 additions and 3 deletions

View file

@ -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"

View file

@ -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 ..