Re: [PATCH JGIT] Propose author and committer in the commit dialog
From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:46:07
Yann Simon [off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java index bc5479a..8438683 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java@@ -57,16 +57,6 @@ private final int tzOffset; - private static String getHostName() { - try { - java.net.InetAddress addr = java.net.InetAddress.getLocalHost(); - String hostname = addr.getCanonicalHostName(); - return hostname; - } catch (java.net.UnknownHostException e) { - return "localhost"; - } - } - /** * Creates new PersonIdent from config info in repository, with current time *@@ -74,14 +64,8 @@ private static String getHostName() { */ public PersonIdent(final Repository repo) { RepositoryConfig config = repo.getConfig(); - String username = config.getString("user", null, "name"); - if (username == null) - username = System.getProperty("user.name"); - - String email = config.getString("user", null, "email"); - if (email == null) - email = System.getProperty("user.name") + "@" + getHostName(); - + String username = config.getAuthorName(); + String email = config.getAuthorEmail(); name = username; emailAddress = email; when = System.currentTimeMillis();
Heh. I meant to write this patch myself yesterday but got
sidetracked and forgot. Thanks.
Its unrelated to the other changes you were making. Please submit
it as its own patch.
Aren't the local "username" and "email" variables now redundant?
Can't we just assign directly to the fields in the object?
Also, I think you should be using getCommitter{Name,Email} here
by default. Sometimes people override the GIT_AUTHOR_* variables
in order to apply patches from others, but they almost never set the
GIT_COMMITTER_* variables. We're using this constructor to create an
identity for use in commit objects, tag objects, or for the reflog.
All three prefer the committer name over the author name.
--
Shawn.