Skip to contentSkip to conversation

Use previous author when amending a commit

PATCH Applied Yann Simon 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

Yann Simon

author
#0 lore raw

PATCH 1/1 Use previous author when amending a commit

In the commit dialog, when amending the commit, the author of the previous commit is proposed as default in the author field.

---
 .../egit/ui/internal/actions/CommitAction.java     |    5 ++++-
 .../egit/ui/internal/dialogs/CommitDialog.java     |   12 ++++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java +4 -1
index ae26770..d30172f 100644
@@ -118,8 +118,11 @@ public void run(IAction act) {
 		commitDialog.setFileList(files);
 		commitDialog.setAuthor(author);
 
-		if (previousCommit != null)
+		if (previousCommit != null) {
 			commitDialog.setPreviousCommitMessage(previousCommit.getMessage());
+			PersonIdent previousAuthor = previousCommit.getAuthor();
+			commitDialog.setPreviousAuthor(previousAuthor.getName() + " <" + previousAuthor.getEmailAddress() + ">");
+		}
 
 		if (commitDialog.open() != IDialogConstants.OK_ID)
 			return;
org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java +12 -0
index fede948..b122fb8 100644
@@ -175,6 +175,7 @@ public void keyPressed(KeyEvent arg0) {
 			amendingButton.setSelection(amending);
 			amendingButton.setEnabled(false); // if already set, don't allow any changes
 			commitText.setText(previousCommitMessage);
+			authorText.setText(previousAuthor);
 		} else if (!amendAllowed) {
 			amendingButton.setEnabled(false);
 		}
@@ -189,6 +190,7 @@ public void widgetSelected(SelectionEvent arg0) {
 					if (curText.length() > 0)
 						curText += "\n"; //$NON-NLS-1$
 					commitText.setText(curText + previousCommitMessage);
+					authorText.setText(previousAuthor);
 				}
 			}
 
@@ -334,6 +336,7 @@ public void setCommitMessage(String s) {
 
 	private String commitMessage = ""; //$NON-NLS-1$
 	private String author = null;
+	private String previousAuthor = null;
 	private boolean signedOff = false;
 	private boolean amending = false;
 	private boolean amendAllowed = true;
@@ -470,6 +473,15 @@ public void setAuthor(String author) {
 	}
 
 	/**
+	 * Pre-set the previous author if amending the commit
+	 *
+	 * @param previousAuthor
+	 */
+	public void setPreviousAuthor(String previousAuthor) {
+		this.previousAuthor = previousAuthor;
+	}
+
+	/**
 	 * @return whether to auto-add a signed-off line to the message
 	 */
 	public boolean isSignedOff() {
Signature · 1 line
1.6.0.4
#1 lore raw
Quoted 4 lines · Yann Simon

In the commit dialog, when amending the commit, the author of the previous commit is proposed as default in the author field.

Much better to read when its by itself.

Applied. Thanks.

Quoted 3 lines
 .../egit/ui/internal/actions/CommitAction.java     |    5 ++++-
 .../egit/ui/internal/dialogs/CommitDialog.java     |   12 ++++++++++++
 2 files changed, 16 insertions(+), 1 deletions(-)
Signature · 1 line
Shawn.