Github Webhook when somebody pulls code from my repository - github

On the event selection screen on Github I don't see an option for "When somebody pulls code from your repository"
Such a webhook would make my work very easy I can automate creation of support tickets based on them for the clients who pull the code.
Is there any hook similar to that or can I add a web-hook of my own for this? Any help or direction is greatly appreciated.

This isn't available directly on the GitHub side, no more than there is a pull or clone hook onthe server side (see "git hooks : is there a clone hook?").
You can clone a GitHub repo without authentication, and that doesn't leave any trace on GitHub side (except maybe in Github own internal logging system, which is not related to Git)

Related

Creating pull requests automatically using jgit

I want to build an automation to create many pull requests on GIT by just click of a button. Input for the API would be source and destination branch. I have come across ways to checkout repository using jgit but did not get anything to create pull request automatically. Please assist.

Can we create a pull request using command-line tooling?

As my browser was crashing I was not able to create a pull request from GitHub UI, I was trying to create a pull request from git console but didn't found any way to create a pull request.
I have also searched for the same over the net but most of the tutorials suggested to create a pull request from UIs only. I just want to be able to handle the pull request like creation, rejection, approved and merging without the browser. Please suggest.
git and github are separate products. github is a service that happens to use git, but it is not part of git, its UI is not a git interface, and git does not have any special support for github functionality.
There is a little potential confusion here, because there are "pull requests" - an integrated feature of github having to do with branch workflow - and there is git request-pull, a seemingly lesser-known feature of git which creates a text message you could send to another repository maintainer to request that they pull changes from your repository.
Naming confusion aside, the "pull request" you want is a feature of github, not git; and so git itself (including git console and any git UI tool) have no command for this. You have to use a github-supplied interface, and AFAIK that means the web UI.
To open a pull request from the command line, you can install the hub set of command-line tools that GitHub supports. This will allow you to create a pull request from a repository with:
hub pull-request
I'm not aware of any similar tools for managing pull requests, though.
git add -p
then
git commit -m "message"
then
git push origin "your_branch"
the pull request will be created in github

Github for Windows Pull Request for remote Bitbucket Repo

Based on this tutorial I was able to successfully connect Github for Desktop with my remote Bitbucket repo.
Looking at the example tutorial repo I see there is an Pull Request option built in the application - great:
However the option is missing when I chose my remote Bitbucket repo:
I couldn't find any option that is reponsible for this.
Anyone knows what affects this behavior?
"Pull Request" is very much a GitHub feature, associated to GitHub repos.
So For BitBucket, the simplest approach is to push your feature branch to the remote repo (which is a BitBucket one, not a GitHub one), and make your PR from there (from the remote BitBucket web GUI, even within the same repo)
Once the PR is initiated, each push done from the GitHub Desktop will complete said PR.
In Bitbucket go to Settings -> Branch Permissions, and add a new branch permission with your name.
EDIT
https://stackoverflow.com/a/37343356/1544886

Commit message hook on github

I am trying to setup a pre-receive hook in github that I used to use on STASH. In STASH, I had a pre-receive hook that used to enforce "A custom commit message that should have a JIRA number included in it".
Now, I am trying to understand what would be the best way to do something similar on github. If I split it up, it would be:
Requiring a custom commit message.
Every commit should include an existing JIRA.
Enforce this on any pull request as well.
Eg: TEST-1 Adding the first commit message.
Can anybody here help me, how can this be done ?
GitHub only offers webhooks, which allows you to listen to and react to certain events, including the push.
But that only allows you to react to a push (like a post-receive hook would), not to prevent it.
You could build a listener to that push event which would:
examine the latest commit just pushed
reset to HEAD~1 if the commit doesn't follow the expected policy (push --force)
But that would be tricky for the user who initially pushed that commit to realize that said commit just disappeared from the GitHub repo.
A better solution would be to setup a bare repo in a server where you could setup that pre-receive hook: if that commit passes, then a post-receive hook would push it to the intended GitHub repo.
But depending on your team, it might be difficult to setup a repo which is accessible by everyone.

GitHub issues as separate repo?

There's already an API for GitHub issues, but has anyone succeeded in making it two-way? That is:
git clone git#github.com:user/repo.issues.git # Like for wiki
editor repo.issues/1.json
git push -u origin master
And voilĂ , a new/updated issue #1!
It could use a pre-receive hook to validate before accepting any pushes, so invalid formatting shouldn't be a problem.
In other words, is there some way to handle the issues of a GitHub project as another GitHub repo?
Aside from using the API, I don't see how this can be done cleanly.
You could put together a (custom) monstrosity that updates a separate GitHub repo with all the issues in said repo at a predefined interval (using the API), but given the effort involved, this better be worth it to you :)