TL;DR: I'm looking for a way to get a TFS git repo to provide instructions for how to create a pull request after a git push origin. I think the best solution is a server-side hook if it's supported in TFS 2018.
I know that if I git push origin new_branch to a github repo, I can get a response that reads something like this:
git push -u origin new_branch
Enumerating objects: 2, done.
Counting objects: 100% (2/2), done.
Writing objects: 100% (2/2), 500 bytes | 500.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
Remote: Create a pull request for ‘new_branch’ on GitHub by visiting:
Remote: http://github.com/example/Demo/pull/new/new_branch
Remote:
* [new branch] new_branch -> new_branch
(note the three lines that begin with "Remote:")
I'm in the process of migrating some code to a git repo hosted by an on-prem instance of Microsoft TFS. Currently, when I run a git push origin new_branch to the TFS repo I get something like this:
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 217 bytes | 1024 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Analyzing objects... (2/2) (53 ms)
remote: Storing packfile... done (47 ms)
remote: Storing index... done (45 ms)
To https://tfsserver.jallc.lan/DefaultCollection/TSG/_git/reponame
c4512bd..80227e1 branchname -> branchname
This git repo and several like it will be used by a group of sysadmins who are new to source control so I would love to find a way to remind them how to submit a pull request.
I believe that the three github lines that begin with "Remote:" are coming from a "post-receive hook" that is run by a post-receive file in /.git/hooks.
I've gotten this (client-side) pre-push script to work:
echo "hi"
echo "Don't forget to generate a pull request. You can do so by navigating to:"
echo "$2/pullrequestcreate?targetRef=master&sourceRef=<your branch> and following the prompts."
But modifying the post-receive and update scripts on my client hasn't had any effect. I'm assuming they need to be modified on the server but have no idea where to find the repo's .git/hooks folder on the TFS server. At any rate, the client-side is much better than nothing.
Any thoughts on how to get the post-receive script to fire on the TFS server would be appreciated.
Many thanks!
TFS 2018 doesn't support git server side hooks.
So your really great idea it's impossible.
I suggest to open a feature request about it like there is about pre-receive hook.