Github pull request template for a specific branch - github

Is it possible to assign a pull request template for a specific branch? Is using query parameters the only work around?

Query parameters are recommended.
As mentioned in "About PR templates":
You must create templates on the repository's default branch.
Templates created in other branches are not available for collaborators to use.

Related

Enable auto-merge before status checks pass

I have a repository where status check and auto merge is enabled. I created a Pull Request using Rest API and want to enable auto merge so that the PR is merged once the status checks are passed. The problem is status checks kick off and pass as soon as I create the PR and I don't get enough time to enable auto merge on the PR using GraphQL API. Is there a way to overcome this?
Please Note: I'm using GitHub Enterprise and we don't have GitHub actions

How to assign a pull request using the REST API?

I'm creating a GitHub pull request using the appropriate REST API. Specifying a single assignee or an assignees (using either the user login or GitHub's internal id) has no effect. The pull request will be created, but without an assignee set. There also seems to be no other endpoint to explicitly assign a pull request to a user. Now I'm wondering whether it's possible at all to set the assignee of a pull request using the REST API?
Every pull request is an issue, but not every issue is a pull request.
For this reason, "shared" actions for both features, like manipulating
assignees, labels and milestones, are provided within the Issues API.
From PR Doc
So, you can use Add assignees to an issue API to set an assignee(s) to a pull request After PR is created. You need to know its number, which is in the JSON body of Create Pull Request's response.
/repos/{owner}/{repo}/issues/{issue_number}/assignees
where issue_number is same as pr_number

Enforcing a Squash merge on Azure DevOps Pull Request using GitPullRequestCompletionOptions

I am attempting to use the Azure DevOps Services REST API to set the PR Completion Options to enforce a squash merge on a Pull Request.
Note: I can't set a branch policy to enforce a squash merge as I am testing certain conditions to see if a squash merge is required or not and attempting to enforce a squash as if the branch policy is set for that PR only.
When I make the following call:
PATCH https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests/{pullRequestId}?api-version=5.0
{
"completionOptions": {
"squashMerge": true
}
}
The response shows the value is set
Yet when attempting to complete the request, I would expect the "Squash changes when merging" checkbox to be ticked and disabled.
If I leave the form as-is and complete the merge, no squash is performed.
If I set bypassPolicy to true, I still see no difference in completion options.
So in summary, I know that the call is successful as the response is coming back with the options set, but the changes don't seem to be coming through to the Pull Request in Azure DevOps.
You could use a policy that enforces this.
If you go to branches in DevOps, select your branch -> policies you can allow only squash merges:
This should make all pull requests into the branch bound by the policy to be done using squash merge.
Here's how it works for Set auto-complete:
Microsoft responded in the developer community forums with the following answer.
In this case there is a difference between expected behavior in the UI
and via the REST endpoint. Setting squashMerge in completion options
tells the PR to complete with a squash only if you complete it with
the REST endpoint. In the user interface we respect user settings to
enable users to choose what they would like to do (if there is no
policy enabled). In this case, you did not enable a policy so a user
can either squash or not. The users preference actually supersedes
what you do with the REST API. If they squash merged the previous PR
we will remember this and create the same default for them on the next
PR.
TLDR: You cannot necessarily control the form default values with
the REST endpoint and should use policy to enforce squash merge (or
expect your users can set the checkbox or not depending on their
preference, but we do not force a default).
It doesn't work that way for me.
Branch Policy vs what is seen when clicking auto-complete

Get the commit comments for a particular branch in stash REST API

My repo is profitmanagement and my branch is release/17.4.0.Apr17, I want to find all the commits and the comments provided during commit for the specific branch.
What is the rest API to use to get this info?
You can use following REST API endpoint provided by Stash:
{your-stash-url}/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits
To find commits on a specific branch, use 'until' request query parameter - e.g.:
{your-stash-url}/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits?until=refs/heads/{branch-name}
Commit message corresponding to each message can be retrieved from the JSON response returned by the REST API.
The documentation is on: https://docs.atlassian.com/DAC/rest/stash/3.11.6/stash-rest.html#idp2461680

Get Pipeline Value of GitHub Issues?

I use ZenHub to manage my Issues on GitHub.
When I go to the detail of an issue I can see the property "pipeline" in GitHub which is exactly the column where the Issue is saved.
Now I want to get the pipeline information out of my issues using the API of GitHub. But none of the Issue-Methods
GET /repos/:owner/:repo/issues or GET /repos/:owner/:repo/issues/:number seem to have any information about the pipeline. Is it hidden anywhere else?
Pipeline is purely a ZenHub feature.
As such, it is not exposed in the Github API Issues (or in any other GitHub API)
A ZenHub public API is in the making (issue 172).
Update: The API is available: ZenHub API
With the Github API v4, you can query the combinedContexts of a commit to retrieve a list of status contexts and check runs for the commit triggering your pipelines.