Suppress Github references from commit message to PR - github

I have a branch in which I (automatically) apply some patches from pull requests.
I do so by committing the PRs' diff and have a commit message like this one
PATCHED | Apply patch https://github.com/randombit/botan/pull/386
Now every time I do that in a commit that is hosted on Github, the PR gets referenced.
In my case this does not add any value to the PR itself, as it is referenced multiple times and not part of any discussion. Can I suppress this referencing from my commit message?
This is what happens when I create a bunch of different commits that have a PR url in the commit message:
Here you can verify that totally unrelated commits create references just by commit message parsing:
https://github.com/webmaster128/dummy-github-ref-test
https://github.com/randombit/botan/pull/386

One simple thing you could do is, not write the reference to the PR # in a way that github will parse it as such.
So, instead of
https://github.com/randombit/botan/pull/386
or
#386
you could try writing just
Pull request number 386
The fanciest thing that I could imagine doing is,
https://myserver.com/botan/pull/386
and then setup your server to redirect such queries to your github page... That way, you still get a clickable hyperlink in the commit messages, but you subvert github's referencing. It's a lot more effort than the alternatives though.
Edit: This is the most complete documentation I could find about github references in gfm. Here is some additional info about the parsing they do for 'closing issues via commit messages'. I couldn't find any more detailed documentation.

Now every time I do that in a commit that is hosted on Github, the PR gets referenced.
This is what pull request is all about, any change made to the given branch is added to the PR and any contributor is being notified about it.
You will keep getting notification until you will do one of the following
Close the pull request
Once the pull request is closed it will not track changes made to the given branch
Unsubscribe
Click on unsubscribe option in the pull request
Close the pull request
Close the pull request by accepting or declining it

Related

Change the target branch of an existing pull request to another fork

I forked a repository A.. say B
I created a pull request from branch B.branch1 TO B.master
The pull request got some review comments.. I resolve them and so on..
I now want to change the base from B.master to A.master(parent repo)
How can I do this in case of an existing PR?
Since I am not seeing the option to change the base branch to another repo..
I know I can create a new pull request but that would lose all the review conversation.
A pull request is an entity that is tied to the repository it was created in. Other repositories (even if forked from the original repository) may have other rules regarding pull requests, code reviews or repository access in general. The developers giving you a code review in fork A might even not be able to do so in fork B.
Therefore you can not move your pull request to another repository.
I suggest you close your current pull request and open a new one. You can link to the old PR and explain the situation so people can still see the code review conversation that was going on in the original PR.

Validate commit message contains Jira Ticket Number when squash merge from GitHub webUI

When doing a squash merge, following a successful Pull Request, on github I would like to validate that the squash merge commit message contains a Jira ticket number. If it does not the squash merge should fail until a proper commit message is entred by the user.
Right now this needs to be done manually and sometimes I forget to include the ticket number I would like an automatic way to make sure I don't forget to do it.
I know that I can use hooks locally to force a Jira Ticket number but I dont care about how the user work on his on branch. I really just want the protected branch commits to all start with a Jira ticket
I do not have github entreprise so I can't use a pre-receive hook.
I have look into github action but not sure this is the proper way to go.
Some Reference but no solutions:
Ensure github PR squash merge commit comments contain issue ID
https://github.com/github/feedback/discussions/8688

How to permanently delete an abandoned pull request in Azure DevOps?

We have an abandoned pull request which we would like to permanently remove. How can this be done? There doesn't seem to be a 'delete' or 'remove' option. Thanks.
How to permanently delete an abandoned pull request in Azure DevOps?
Sorry for any inconvenience.
I'm afraid there is no such way to permanently delete an abandoned pull request in Azure DevOps at this moment.
Microsoft thinks that data retention and traceability is important to a lot of our customers - it's not as simple as always providing CRUD operations for every artifact. But more and more customers are requesting delete pull requests, or at least the ability to delete abandoned pull requests.
Just like Spevacus comment, this feature is under Review, and Microsoft replied:
Your suggestion has been queued up for prioritization. Feature
suggestions are prioritized based on the value to our broader
developer community and the product roadmap. We may not be able to
pursue this one immediately, but we will continue to monitor it up to
90 days for community input
You could vote and add your comments for this feedback. When there are enough community votes and comments with reliable feedback, the product team members will take this feature request seriously.
Hope this helps.
While an abandoned pull request cannot currently be permanently deleted in Azure DevOps, it can be closed. The comment/update history will remain, but the pull request will not show up in the "Abandoned" list.
Delete the pull request's source branch if it still exists.
Create a new branch based on the main branch with the same name as the original source branch.
Reactivate the pull request
Close the pull request
The new status will be "Completed"
I also wanted to do this so that I wouldn't have an open pull request showing in open pull requests forever. So you can't delete the pull request, but at least you can get it marked as closed/completed. As a workaround until the delete feature is added you can do the following:
Create a temporary branch, let's say we call it "DeleteMe"
In your pull request, change the destination branch to DeleteMe
Complete the pull request.
In DeleteMe branch, if you want this updated with any new changes then you can make it updated to current. Otherwise just make any change to a file. You can add in a space on a comment for instance.
Create a new pull request to merge DeleteMe back into the original branch.
Complete the pull request and delete the DeleteMe branch.
Now the pull request will be closed/completed.
My priority was to prevent an inadvertent merge to Prod.
Hence you can:
add yourself as reviewer, then Reject; Save
as above, change the target branch to a dummy branch; Save
place [DELETED} at start of the title; Save
set the PR to Draft - that resets your rejected review
https://learn.microsoft.com/en-us/azure/devops/release-notes/2018/sprint-143-update#draft-pull-requests
or "Abandon" the PR

Get branch to which a Github Pull Request comment belongs

I'm building the Github PR comment to Travis build thing from my previous question (since it does not seem to exist), but I'm running into the problem:
Github sends a webhook call for Issue comments (which is how they call PR comments)
That comment payload has an issue object attached to it.
There is a lot of stuff in the issue but information about what branch the changes are in is not one of them.
I also don't see an obvious way of retrieving the branch.
Am I missing something here?
Turns out I wasn't missing anything, Github answered:
Thanks for sharing your thoughts -- I'll pass them along to the team
working on webhooks but I don't expect any changes here in the near
future. For now, for each pull request that's opened -- you can save
the head and base branch information on your end. Then, once you
receive an issue comment webhook delivery, you will know which pull
request and which branches it is about without needing to call the
API.

On Github, how do I find what pull requests individual file commits belong to

On GitHub, I can see the history of commits of a file under .../commits/master/filename. What I want to know is, assuming these changes were merged into master via Pull Requests, what Pull Request did the change come from? Is there an easy way to do that?
Since Oct. 13, 2014, this should be easier:
Linking merged pull requests from commits
We've been including the containing branches and tags on commit pages to give you more context around changes. Now, commits in a repository's default branch will also show you the pull request that introduced them.
In the pull request, you can see the discussion around why the commit was introduced, and get a clearer picture of the reason for the change.
As always, if you know the commit SHA, you can skip the commit page and search for the pull request directly.
For instance:
You can see for the file hakimel/reveal.js/plugin/markdown/markdown.js, my contribution now comes with a reference to the PR #734 it originated.
Note however that:
neither GitHub Get single commit API, like https://api.github.com/repos/hakimel/reveal.js/commits/f2097417daca80b2caaed2661ee646e861d789c8
nor GitHub Get a commit API, like https://api.github.com/repos/hakimel/reveal.js/git/commits/f2097417daca80b2caaed2661ee646e861d789c8
will include the reference to the PR...