Github API PushEvent - github-api

Why is it that not all commits show up as PushEvent and vice versa?
For example, the PushEvents returned from the Github API for this repo do not show the initial commit; also not all events returned from the api call show up as commits on the repo commits webpage, presumably because not all PushEvents are merged.
I need some clarification as to the relationship between PushEvents and commits as shown on a projects' github page.

Related

how to delete a pull request with pull number using github api [duplicate]

I accidentally made a wrong pull request and ended up closing the request myself. It's in a closed state right now but it's accessible via direct URL and showing on my activity bar.
Is there any way to delete a pull request completely so it's no longer accessible via URL or shows up on your activity history?
There is no way you can delete a pull request yourself -- you and the repo owner (and all users with push access to it) can close it, but it will remain in the log. This is part of the philosophy of not denying/hiding what happened during development.
However, if there are critical reasons for deleting it (this is mainly violation of Github Terms of Service), Github support staff will delete it for you.
Whether or not they are willing to delete your PR for you is something you can easily ask them, just drop them an email at support#github.com
UPDATE: Currently Github requires support requests to be created here: https://support.github.com/contact
5 step to do what you want if you made the pull request from a forked repository:
reopen the pull request
checkout to the branch which you made the pull request
reset commit to the last master commit(that means remove all you new code). Command: git reset --hard commit_hash_here
git push --force
delete your forked repository which made the pull request
And everything is done, good luck!
This is the reply I received from Github when I asked them to delete a pull request:
"Thanks for getting in touch! Pull requests can't be deleted through the UI at the moment and we'll only delete pull requests when they contain sensitive information like passwords or other credentials."
It's very easy actually:
You can empty it, that's the best you could do.
Go to your local
Copy your local branch unwanted-branch (against which the PR was opened) to a new branch new-branch. This copying is relevant if you want to back it up for any reason. Otherwise go to step 3.
$ git branch -b new-branch
$ git merge unwanted-branch
$ git push
Empty the unwanted-branch
$ git checkout unwanted-branch
$ git reset --hard HEAD~n #n is the number of commit the branch has
$ git push -f
Enjoy, your PR is empty and closed now ;). Go to remote and delete the unwanted-branch if it bothers you.

Description of "Allow requestors to approve their own changes" is confusing

The description on this page https://learn.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops#require-a-minimum-number-of-reviewers says:
If Allow requestors to approve their own changes is selected, the creator of the pull request may vote on its approval. If not, they can still vote Approve on their pull request, but their vote won't count toward the Minimum number of reviewers.
This means it is assumed that the person that did changes on the source branch is at the same time the creator of the pull request. In our case often a different person than the developer is creating the pull request. Is this setting then only related to the creator of the pull request (and not caring about the commit pusher) or the person that pushed commits to be reviewed within the pull request?
If it is only about the creator of the pull request then the name of this setting should be changed since it has nothing to do with the actual changes (=commits) on source branch of the pull request.
Did I misunderstand something here?
Thank you
You are making a good point, Azure DevOps is implying here that the person who worked on a branch is also the initiator of the PR. This is not something that is 100% guaranteed, because it can happen that I created a dev branch, worked on code, made several commits, then my teammate creates a PR from my branch.
(The "most recent pusher" setting is probably closer to what you are looking for, which controls based on who pushed the latest commit from a local repository.)

Finding the ObjectId for Annotated Tags

I"m trying to get the objectID(SHa1d) of a commit.
Is there a way to retrieve the value?
You can get the objectId through Refs - List rest api.
https://dev.azure.com/{organization}/_apis/git/repositories/{repositoryId}/refs?filter=tags/&api-version=5.1-preview.1
However, if you want to get the information of annotatedtags from the commit's response, I am afraid this is currently not possible. The commit's response currently does not contain tags information.
Here is a uservoice for the same issue has been submitted on Developer Community forum. You can vote and add your comments for this feedback. Our PM and Product Group are reviewing these suggestion regularly and considering take it as plan.
In addition, you can retrieve tags based on commit id from Repos-> Tags in web UI.
The Commits - Get Commits API for Azure DevOps Git should serve the Commit ID as well in the response, along with retrieving git commits for a project. Check out the examples given in the same page for looking at some sample requests and responses.
Here is one:
Hope this helps!

github notification to nodeJS when master get a commit

Is it possible if my master branch in my github repo gets an update that my nodeJS server got a notification ? so i can do stuff with it ? like get the version tag and commit message ?
First you need to go to your repo, and click through this sequence:
Settings -> Webhooks & Services -> Add webhook
Then paste the url where github will submit data for each new commit. You can find examples of payload in example.
Then implement the logic needed in the backend to work with info about new commits.

Need github repo commit list without based upon user

Im trying to get the commit list from GitHub repo using its API.
I am getting the commit list but its based upon particular user.
I need the list based upon the commit happened.
Below is the url I am using:
https://api.github.com/repos/user_name_here/repo_name_here/commits?access_token=XXXXXXXXXXX&per_page=5
It seems that the commits returns by the API will list all the commits from a particular repo, for all authors (ie not based on a user).
See for instance the commits of GitLabhq repo:
https://api.github.com/repos/gitlabhq/gitlabhq/commits
You will get all commits, without restriction. You will get both the original author and committer name as well.

Resources