Adding default reviewers to Github repository - github

I followed the instructions here https://help.github.com/articles/about-codeowners/ but it doesn't seem to work. I even added the CODEOWNERS file at both the root and .github directory. The reviewers specified in the CODEOWNERS file are not selected automatically when a pull request is created. See screenshots below. Onyone who has set this up, could you point to where the problem is. Thank you.

You need to be sure that your base branch has:
the 'Protect this branch' flag activated
the 'Require pull request reviews before merging' flag activated
the 'Require review from Code Owners' flag activated
Then in the CODEOWNERS file, located either in the root of the repo or in the .github subfolder, you need to have either a user described with '#user', a user described with his email like 'user#domain.com', or a team described with '#org/teamname'.
You will need also to be sure that:
your contributors (users and teams) have for each of them the 'write' access to the repo
the team is not a 'secret' team, only the 'visible' teams would be taken into account

Double-check the CODEOWNERS file syntax
The pattern is followed by one or more GitHub usernames or team names using the standard #username or #org/team-name format.
(I don't see # in your case)
You can also refer to a user by an email address that has been added to their GitHub account, for instance user#example.com.
If the syntax is correct, then you can contact GitHub support to have them investigate.
The OP Pratheep actually find this is working:
You need the # and referring to my last screenshot above, you don't see the reviewers in the list when creating the PR.
But once the PR is created, then you will see the reviewers in the list.
I believe it was by design not to show. Because if you show the reviewers in that list before the PR is created, the names can be removed.
This way no one can create a PR without notifying the codeowners/default reviewers.

Related

Why am I able to push and send/receive pull requests but not on the contributor list in github?

I'm been working in a team of four. I'm in the collaborator list. I'm able to commit, push, send pull requests and merge in our repo. My teammates can see my changes, but everyone is on the contributor list except me.
I double checked my email address, make sure the email I used in my local setting is the same with my default email in the github account.
We have changed the owner of the project once, and I'm still using the old url. Is this the reason for that?
I found the github has a complex rule for you be considered as a contributor. Here's the doc of it.
https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-profile/managing-contribution-settings-on-your-profile/why-are-my-contributions-not-showing-up-on-my-profile
You have to commit to the main/default branch or make pull requests. To commit into other branches won't count.
Also, to use the old project url is definately one problem. In the project insight, everyone's profile is linked with their username. While mine is only a username with no user icon.
I think I just accidentally hit into one of the corner cases, but I'm still very confused of this design pattern.

Set default team permissions on new repositories?

When I create a repo on GitHub, it's almost always because I have code to push that is ready for review. But by default, only the organization admin can see a new repo right after it's been created. This prevents me from adding other reviewers to the PR that I create immediately after that.
Is there a way to set this up so that everyone on my team will appear in the list of potential reviewers for every new repo as it's created?

Accepted merge requests author not shown as contributor

Recently I've started a new open source android project on GitHub (Open Weather App). One person forked the repository and made some changes, then he created a pull request and I accepted it by pressing this green button:
Everything worked just fine, the pull request was merged into master. However, the problem is that he did not appear in the contributors list. It still does say 1 contributor, which is me:
What could be the reason for him not to appear on the list, and how can I solve this issue?
I feel responsibility for him. I even added him to collaborators list, yet he still does not appear as a contributor.
At Contributions that are counted are 3 points listed which must be met by a contributor:
I checked your repo and the pull request and it seems like this point is not met:
The email address used for the commits is associated with your GitHub
account
Are you sure it is not described here?
Why are my contributions not showing up on my profile?

Set a default reviewer

I do pull requests in a repo where it's always the same person reviewing.
I would like to set him as the default reviewer so that I don't always have to choose him at each pull request, it'd be automatic.
How to do that ?
GitHub has the ability to set the default reviewer using a CODEOWNERS file.
Code owners are automatically requested for review when someone opens a pull request that modifies code that they own. When someone with admin permissions has enabled required reviews, they can optionally require approval from a code owner.
To use a CODEOWNERS file, create a new file called CODEOWNERS in the root, docs/, or .github/ directory of the repository, in the branch where you'd like to add the code owners.
You should add .github/CODEOWNERS file with users to send PR to.
Example to send PR for any change on codebase represented by *:
## code changes will send PR to following users
* #option1-user1 #option1-user2 #option2-your-org/team-name
See: https://docs.github.com/en/enterprise/2.18/user/github/creating-cloning-and-archiving-repositories/about-code-owners
Note: .github/CODEOWNERS should be in main branch to be effective.

Can I associate a GitHub user with his commits by name only, BitBucket-style?

I've seen Github shows name instead of a linked username in commits and I realise that the right thing to do is to link by email. However, I already have a repository with a whole bunch of commits whose email is "none#none".
On BitBucket, I can specify a per-project mapping of committer name to BitBucket account, and this has worked well enough. Is there anything like this on GitHub?
If not, what other options are there, short of leaving the commits unlinked and rewriting the entire history?
You can use .mailmap file in your repo, for mail aliased (as stated in "“Alias” git authors/committers?")
You also can add another email in your Email setting account.
But both solutions don't scale well when several authors use the same none#none email.