How to block GitHub pull request when Jira ticket is not present - github

At my previous job a pull request in Github was only allowed to be merged if the new branch, the pull request title, and all of the commits had a Jira ticket number in the title.
I was sure that it was something trivial. However, I cannot figure out how to do it.
Did anyone implement something similar?

You can implement a simple protection using name pattern for the new branch you are creating.
You can read about it here:
managing-a-branch-protection-rule

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.

Viewing pull requests that I need to comment on

Does anyone know of a way in GitHub to see pull requests were I am mentioned and either I have not yet commented or commits have been added since I last commented?
If you watch a repository like this, you'll be notified by everything that happens on that particular repo:
New commits will appear on your on-site dashboard and comments on commits/issues/PRs (by the way "PR" stands for "Pull Request) as well as opened/closed/merged PRs and issues will come up both by e-mail and on your dashboard.