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.

---
I remove the modifications of PersonIdent and send them in another patch.

 .../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 +
 4 files changed, 126 insertions(+), 34 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.
Signature · 1 line
1.6.0.4
#1 lore raw
Quoted 10 lines · Yann Simon

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.

Far too many things in one change. Please break these apart into multiple commits so they are easier to review and test in isolation.

Quoted 1 line

I remove the modifications of PersonIdent and send them in another patch.

Thanks, that one is now applied.

Quoted 14 lines
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java +1 -2
index ae26770..9a9d494 100644
@@ -99,15 +99,16 @@ public void run(IAction act) {
 		}
 
 		String author = null;
+		String committer = null;
 		if (repository != null) {
 			final RepositoryConfig config = repository.getConfig();
 			author = config.getAuthorName();
-			if (author != null && author.length() != 0) {
-				final String email = config.getAuthorEmail();

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java public void run(IAction act) { · line 111

Quoted 10 lines
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java +6 -4
-				if (email != null && email.length() != 0) {
-					author = author + " <" + email + ">";
-				}
-			}
+			final String authorEmail = config.getAuthorEmail();
+			author = author + " <" + authorEmail + ">";
+
+			committer = config.getCommitterName();
+			final String committerEmail = config.getAuthorEmail();
+			committer = committer + " <" + committerEmail + ">";

Don't you mean getCommitterEmail() here?

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java public void run(IAction act) { · line 126

Quoted 11 lines
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java +4 -1
@@ -117,9 +118,13 @@ public void run(IAction act) {
 		commitDialog.setAmendAllowed(amendAllowed);
 		commitDialog.setFileList(files);
 		commitDialog.setAuthor(author);
+		commitDialog.setCommitter(committer);
 
-		if (previousCommit != null)
+		if (previousCommit != null) {
 			commitDialog.setPreviousCommitMessage(previousCommit.getMessage());
+			PersonIdent previousAuthor = previousCommit.getAuthor();
+			commitDialog.setPreviousAuthor(previousAuthor.getName() + " <" + previousAuthor.getEmailAddress() + ">");

Isn't this a bug fix for "amend" so that the original author is reused when amending the prior commit? Please mention it in the commit message; and ideally this should be its own change.

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java private static String getFileStatus(IFile file) { · line 355

Quoted 5 lines
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java +1 -0
@@ -312,6 +352,7 @@ private static String getFileStatus(IFile file) {
 			}
 
 		} catch (Exception e) {
+			e.printStackTrace();

Would it be better to log this through an Activator so it shows up in the Error Log view?

org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java private static String getFileStatus(IFile file) { · line 366

Quoted 6 lines
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java +1 -0
@@ -321,6 +362,7 @@ private static String getFileStatus(IFile file) {
 	 * @return The message the user entered
 	 */
 	public String getCommitMessage() {
+		commitMessage.replaceAll(Text.DELIMITER, "\n"); //$NON-NLS-1$
 		return commitMessage;

String is immutable. This replaceAll is a noop. You probably meant to return the return value of the replaceAll method.

There may be other comments for these changes; it would be easier to review if they were more broken up into independent commits.

Signature · 1 line
Shawn.