Skip to contentSkip to conversation

Propose author and committer in the commit dialog

PATCH In review Yann Simon 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

Yann Simon

author
#0 lore raw

PATCH 1/1 Propose author and committer in the commit dialog

Add a field 'committer'.
The fields 'author' and 'committer' are populated with the values found in the configuration.

Validate the author and the committer.

Add the signed-off line in the comment text box when the user clicks on the signed-off checkbox.

Use Text.DELIMITER as line break for plateform independance.

A default PersonIdent is an author and gets the values from the configuration.

---
 .../src/org/spearce/egit/ui/UIText.java            |    6 +
 .../egit/ui/internal/actions/CommitAction.java     |   55 +++++------
 .../egit/ui/internal/dialogs/CommitDialog.java     |   97 +++++++++++++++++++-
 .../src/org/spearce/egit/ui/uitext.properties      |    2 +
 .../src/org/spearce/jgit/lib/PersonIdent.java      |   20 +----
 5 files changed, 128 insertions(+), 52 deletions(-)
org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java +6 -0
index d74f53e..249f2a0 100644
@@ -584,6 +584,9 @@
 	public static String CommitDialog_CommitChanges;
 
 	/** */
+	public static String CommitDialog_Committer;
+
+	/** */
 	public static String CommitDialog_CommitMessage;
 
 	/** */
@@ -596,6 +599,9 @@
 	public static String CommitDialog_ErrorInvalidAuthorSpecified;
 
 	/** */
+	public static String CommitDialog_ErrorInvalidCommitterSpecified;
+
+	/** */
 	public static String CommitDialog_ErrorMustEnterCommitMessage;
 
 	/** */
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java +25 -30

98 lines not on this page · raw message

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java +93 -4

186 lines not on this page · raw message

org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties +2 -0
index 52fa4f8..142b426 100644
@@ -226,10 +226,12 @@ CommitDialog_AmendPreviousCommit=A&mend previous commit
 CommitDialog_Author=&Author:
 CommitDialog_Commit=&Commit
 CommitDialog_CommitChanges=Commit Changes
+CommitDialog_Committer=Committer:
 CommitDialog_CommitMessage=Commit &Message:
 CommitDialog_DeselectAll=&Deselect All
 CommitDialog_ErrorInvalidAuthor=Invalid author
 CommitDialog_ErrorInvalidAuthorSpecified=Invalid author specified. Please use the form:\nA U Thor <[email protected]>
+CommitDialog_ErrorInvalidCommitterSpecified=Invalid committer specified. Please use the form:\nCommi T Ter <[email protected]>
 CommitDialog_ErrorMustEnterCommitMessage=You must enter a commit message
 CommitDialog_ErrorNoItemsSelected=No items selected
 CommitDialog_ErrorNoItemsSelectedToBeCommitted=No items are currently selected to be committed.
org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java +2 -18
index bc5479a..8438683 100644
@@ -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();
Signature · 1 line
1.6.0.4
#1 lore raw
Quoted 28 lines · Yann Simon
org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java +0 -13
index bc5479a..8438683 100644
@@ -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");

org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java private static String getHostName() { · line 71

Quoted 10 lines
org.spearce.jgit/src/org/spearce/jgit/lib/PersonIdent.java +2 -5
-
-		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.

Signature · 1 line
Shawn.