Need help on GitHub usage. I wonder if there is a way to communicate with a github.com user i.e. write the user a message when only username/id is given on their GitHub page? Does GitHub have this social feature?
Although GitHub removed the private messaging feature, there's still an alternative.
GitHub host git repositories. If the user you're willing to communicate with has ever committed some code, there are good chances you may reach your goal. Indeed, within each commit is stored some information about the author of the change or the one who accepted it.
Provided you're really dying to exchange with user user_test
Display the public activity page of the user: https://github.com/user_test?tab=activity
Search for an event stating "user_test pushed to [branch] at [repository]". There are usually good chances, they may have pushed one of his own commits. Ensure this is the case by clicking on the "View comparison..." link and make sure the user is listed as one of the committers.
Clone on your local machine the repository they pushed to: git clone https://github.com/..../repository.git
Checkout the branch they pushed to: git checkout [branch]
Display the latest commits: git log -50
As a committer/author, an email should be displayed along with the commit data.
Note: Every warning related to unsolicited email should apply there. Do not spam.
This method was working as of Jan 2023
Copy and paste the next line into your browser (feel free to
bookmark it): https://api.github.com/users/xxxxxxx/events/public
Find the GitHub username for which you want the email. Replace the
xxxxxxx in the URL with the person's GitHub username. Hit Enter.
Press Ctrl+F and search for “email”.
As suggested by qbolec, the above steps can be done by using this snippet:
<input id=username type="text" placeholder="github username or repo link">
<button onclick="fetch(`https://api.github.com/users/${username.value.replace(/^.*com[/]([^/]*).*$/,'$1')}/events/public`).then(e=> e.json()).then(e => [...new Set([].concat.apply([],e.filter(x => x.type==='PushEvent').map(x => x.payload.commits.map(c => c.author.email)))).values()]).then(x => results.innerText = x)">GO</button>
<div id=results></div>
Source: Matthew Ferree # Sourcecon
Simply create a dummy repo, open a new issue and use #xxxxx to notify the affected user.
If user has notification via e-mail enabled they will get an e-mail, if not they will notice on next login.
No need to search for e-mail address in commits or activity stream and privacy is respected.
For lazy people, like me, a snippet based on Nikhil's solution
<input id=username type="text" placeholder="github username or repo link">
<button onclick="fetch(`https://api.github.com/users/${username.value.replace(/^.*com[/]([^/]*).*$/,'$1')}/events/public`).then(e=> e.json()).then(e => [...new Set([].concat.apply([],e.filter(x => x.type==='PushEvent').map(x => x.payload.commits.map(c => c.author.email)))).values()]).then(x => results.innerText = x)">GO</button>
<div id=results></div>
Github said on April 3rd 2012 :
Today we're removing two features. They've been gathering dust for a while and it's time to throw them out : Fork Queue & Private Messaging
Source
Here is another way:
Browse someone's commit history (Click commits which is next to branch to see the whole commit history)
Click the commit that with the person's username because there might be so many of them
Then you should see the web address has a hash concatenated to the URL. Add .patch to this commit URL
You will probably see the person's email address there
Example: https://github.com/[username]/[reponame]/commit/[hash].patch
Source: Chris Herron # Sourcecon
Besides the removal of the github messaging service, usage was often not necessary due to many githubbers communicating with- and advocating twitter.
The advantage is that there is:
full transparency
better coverage
better search features for tweets
better archiving, for instance by the US Library of Congress
It is probably no coincidence that stackoverflow doesn't allow private messaging either, to ensure full transparency. The entire messaging issue is thoroughly discussed on meta-stackoverflow here.
Does GitHub have this social feature?
If the commit email is kept private, GitHub now (July 2020) proposes:
Users and organizations can now add Twitter usernames to their GitHub profiles
You can now add your Twitter username to your GitHub profile directly from your profile page, via profile settings, and also the REST API.
We've also added the latest changes:
Organization admins can now add Twitter usernames to their profile via organization profile settings and the REST API.
All users are now able to see Twitter usernames on user and organization profiles, as well as via the REST and GraphQL APIs.
When sponsorable maintainers and organizations add Twitter usernames to their profiles, we'll encourage new sponsors to include that Twitter username when they share their sponsorships on Twitter.
That could be a workaround to leave a message to a GitHub user.
Simplest solution that worked for me very well is just to put the username of that particular user or repository link of corresponding user!
<input id=username type="text" placeholder="Github Username or Repo link">
<button onclick="fetch(`https://api.github.com/users/${username.value.replace(/^.*com[/]([^/]*).*$/,'$1')}/events/public`).then(e=> e.json()).then(e => [...new Set([].concat.apply([],e.filter(x => x.type==='PushEvent').map(x => x.payload.commits.map(c => c.author.email)))).values()]).then(x => results.innerText = x)">GO, Get email!</button>
<div id=results></div>
Related
I'm using JavaScript and Octokit to dynamically create repositories in an organization and set a series of options.
Everything works, except adding write permissions to a team for the repository created.
Just to be clear, by write permission I mean the ones that can be set through the repository settings:
Settings > Collaborators and teams > Manage Acccess > Role: Write
What I've been trying to use so far, was the octokit.rest.teams.addOrUpdateRepoPermissionsInOrg function in Octokit, documented here, like this:
octokit.rest.teams.addOrUpdateRepoPermissionsInOrg({
org: "org-name",
team_slug: "team-name",
owner: "owner-name",
repo: "repo-name",
permission: "write",
}
When doing this, I receive a Validation Failed error.
Checking the relative documentation on the GitHub API docs, it effectively seems that the valid values for permission are: pull, push, admin, maintain, triage
So I guess that I'm simply using the wrong function.
But what's the correct one to change that kind of permission?
I managed to make it work: apparently, the push permission in the API corresponds to the write permission in the GitHub web interface.
FYI: this seems like a discrepancy, so I opened an issue.
Want to restrict all users in GitHub from deleting an existing tag. Please let us know if there is any way to achieve it. I have found one article where we can protect branches: https://github.com/blog/2051-protected-branches-and-required-status-check
Similarly if there is something through which we can protect tags in GitHub.
That seems to have been implemented in March 2022, as illustrated by the changelog post:
Tag protection rules
Repository owners can now configure tag protection rules to protect tags in all public repositories and in private repositories on the Pro, Teams or Enterprise plans on GitHub.
Once protected by a tag protection rule, tags matching specified patterns can only be created and deleted by users with "Maintain" or "Admin" permissions to the repository.
For more information, see our documentation.
And, now in public beta:
Protected tags
Our beta tag protection feature gives repo admins the option to protect tags on their repo.
If they choose to do so, only maintainers and admins will be able to create these tags, and only admins will be able to modify or delete these tags.
Tags are protected by patterns - you could protect all tags by using the "*" pattern, but you don’t have to.
To set up and manage these tag protections, we’ve introduced three endpoints, which any repo admin should be able to use:
GET /repos/{owner/{repo}/tags/protection
Returns a list of tag protection rules.
POST /repos/{owner}/{repo}/tags/protection
Creates a new tag protection rule. Payload must include a pattern - example:
curl -" "Authorization: token $GITHUB_TOK"N"
-XPOST -d '{"pattern": "*"}'
https://api.github.com/repos/JasonEtco/testing/tags/protection
{
"id": 123456,
"pattern": "*",
"created_at": "2022-01-12T12:01:47.094-05:00",
"updated_at": "2022-01-12T12:01:47.094-05:00"
}
DELETE /repos/{owner}/{repo}/tags/protection/{tag_protection_id}
Deletes a tag protection rule.
GitHub currently does not support protecting tags. This means anyone with write access to a repository can push any tag and delete any existing tag. (Unfortunately, I could not find references for this. Thus, I today did an experiment from an account with Collaborator access to a repository owned by a different account, and the Collaborator could push any tag and delete any existing tag. Repository settings only allow protecting branches, not tags.)
There is an open feature request in the GitHub support community, where a GitHub staff member commented in February 2019 that they "are tracking an internal issue about this".
As a workaround, GitHub support suggests to "set up a webhook to be notified if a tag is deleted using [their] API: https://developer.github.com/v3/activity/events/types/#deleteevent ". You could create a GitHub Actions workflow triggered by the delete event, where you could check whether a user (sender field) is allowed to delete a given tag. If deletion is not allowed, you could restore the tag.
Competing products, such as GitLab and Bitbucket Server, apparently do support tag protection.
I use cla-assistant as my GitHub Contributor License Agreement (CLA) management bot.
Is it possible to change the URL of the gist containing the CLA? (without having to export the list of users who signed the CLA, unlink the repository, relink the repository with a a new gist URL and import the user list)
This isn't possible.
From one of the repository maintainers on https://github.com/cla-assistant/cla-assistant/issues/223:
unfortunately not. It works only the (long) way you have described.
What is the difference between GitHub username and GitHub ID? I was asked for my Github ID for a certain project and I happened to give my username. But the person is unable to find me on GitHub with my username. So I got a GitHub ID from the below URL:
http://caius.github.io/github_id/
But I'm unable to find this ID from my account directly. Where can I find this in my GitHub account? It would be great if someone could elaborate on this.
Thank You.
It can be easily retrieved using GitHub API:
https://api.github.com/users/your_github_user_name
where instead of your_github_user_name you must use the desired GitHub username.
Example:
https://api.github.com/users/github
It can be easily retrieved using Github API.
Example: https://api.github.com/users/username
It can be easily retrieved using Github API. If you cannot use the API answer or from http://caius.github.io/github_id/ you can go to github --> settings --> emails , under the Primary email address you will find {id}+{user_name}#users.noreply.github.com. The format is simillar to this: 50826640+hirwablessing#users.noreply.github.com, that 50826640 is the id.
From this answer
If you cannot use the API answer or from http://caius.github.io/github_id/ you can go to github --> settings --> emails, under the Primary email address you will find {id}+{user_name}#users.noreply.github.com.
This is at least true if you have Keep my email address private checked.
I have this text in the Keep my email address private explanation, and I'm guessing this will be there even if it is turned off.
Look for 'noreply' in the emails section.
If you do have the GitHub Id but need to find the username / login you can do it like this with the List users endpoint:
Subtract the id by 1 and run the following query. My GitHub Id is 4015237 and therefore the query parameter since receives the value 4015236.
https://api.github.com/users?since=4015236&per_page=1
https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#list-users
Description for since:
Query parameters - since - A user ID. Only return users with an ID
greater than this ID.
Don't use the ID stated in other answers I tried this and it didn't work and said it was invalid on AWS.
It's located on the main GIT repository. Those random letters and numbers are below the add file button with no description, obviously. Not only that but it's clickable if you click into it you'll find a much longer commit ID. You want the longer one.
Everyone loves completely unnecessary complexity in a platform!!
Step-1: Go to this link:
https://caius.github.io/github_id/
Step-2 Enter your Github username
You got it!
The second method is:
Go to your GitHub account and click on the Settings option.
Go to the emails section.
You id is listed there. The format is:
{id}+{user_name}#users.noreply.github.com
I'm trying to use GitHub's API through the library "github-java-sdk".
I want to identify the lastest 100 committers of one repository.
For instance, when I run this command to analyse return data : http://github.com/tinoucas/dwm-tinou/network_data_chunk?748b1c901dc01fd14c4f8a1f8985525612683295
I noticed that some commits don't have the field "login" assigned.
Could you tell me why it's empty ?
How I could identify one committer who hasn't the login property assigned ?
After having cloned this repository, printing out the header of one of the suspicious commit, one would notice within the Author and Committer fields a very weird email information.
$ git show 7c3efbad3d540d34726340bf727889d87b5376e4 --format=raw
commit 7c3efbad3d540d34726340bf727889d87b5376e4
tree a99909e793befcccb9f8b9f5aff3a789148ee9da
parent c4e62ae697937477a1b847e5a9a4caa906d0b130
author tinou <tinou#polter.(none)> 1234738874 +0100
committer tinou <tinou#polter.(none)> 1234738874 +0100
Comparing this to the information contained in the parent commit, the email is different
$ git show c4e62ae697937477a1b847e5a9a4caa906d0b130 --format=raw
commit c4e62ae697937477a1b847e5a9a4caa906d0b130
tree 61679418f1fe1acfe53440cb91092bb16f64c14a
parent e0bb39e6de991417ea2c55ebea17378d58480476
author tinou <tinoucas#gmail.com> 1231278215 +0100
committer tinou <tinoucas#gmail.com> 1231278215 +0100
If we use the GitHub web interface to display those two commits
The first one displays a plain "tinou" as author
The second one displays an enhanced clickable "tinoucas" author information along with its gravatar
My guess would be that GitHub uses the email address from the commits to retrieve the matching GitHub login. When the email address is obfuscated or can't be matched, no login information can be sent out through the API.