HgGit: "Invalid Email Address" on GitHub

I started using the HgGit extension for mercurial to have a copy of the repository in GitHub. Almost everything works fine, but on GitHub commits I see invalid-email-address (author) instead of my username. Is there a way to correctly show the username in this case?

+7
source share
2 answers

Username in Mercurial usually has the form:

 Name < email@domain.com > 

Git is also usually configured with a name and email address for the user.

You may need to include the email address in your username in the Mercurial configuration so that the username in commits works correctly on github .

This username does not have to match your username on any particular website, it is used to record information. If you wanted to be the same, how could you ever push forward changes made by someone else?

For example, my bitbucket username is different from my Mercurial username in my commits, and the way I store my bitbucket username and password outside the bitbucket paths in hgrc is to use my [auth] .hgrc / Mercurial.ini section:

 [auth] bb.prefix = bitbucket.org bb.schemes = https bb.username = myBBusername bb.password = myBBpassword 

Placing a password here is optional (you will be asked), but there are safer alternatives for storing it, such as expanding the set of keys .

However, itโ€™s a little late to change the username on existing change sets (you will have to rewrite the entire repo history).

+1
source

To fix the "invalid email address" problem, you must find the old "git author names" in the commits and set the new author and committer names and email addresses for the commits before you click the newly converted repository on GutHub.

This fix (search and replace ...) is done using the git filter-branch command. You can see a usage example here: (is it dead now ?!) Mercurial before Git, resolving an "invalid email address"

[Edited:] Since the link above is dead, I will give an example of the file "fix-user-email.sh" below. As you can see, here two versions of the authorโ€™s name are translated into the same valid GIT name / email pair:

 git filter-branch --env-filter ' an="$GIT_AUTHOR_NAME" am="$GIT_AUTHOR_EMAIL" cn="$GIT_COMMITTER_NAME" cm="$GIT_COMMITTER_EMAIL" if [ "$GIT_AUTHOR_NAME" = "peter.pen" ] then cn="peterpen" cm=" peterpen@example.com " an="peterpen" am=" peterpen@example.com " fi if [ "$GIT_AUTHOR_NAME" = "peterpen" ] then cn="peterpen" cm=" peterpen@example.com " an="peterpen" am=" peterpen@example.com " fi export GIT_AUTHOR_NAME="$an" export GIT_AUTHOR_EMAIL="$am" export GIT_COMMITTER_NAME="$cn" export GIT_COMMITTER_EMAIL="$cm" ' 

I personally executed the commands from the above page step by step in the cygwin bash window (in fact I ran / modified / restarted the script to simplify my life, of course :-)) and checked the results using GIT -GUI ...

When you are ready to check out the repository on GitHub,

  • Create a new repository on GitHub and do nothing with it!
  • Push the converted repo to the GIT hub. If something else is not very good, remove the repo from GitHub and re-create the repo with the same name ...
+2
source

Source: https://habr.com/ru/post/894283/


All Articles