* [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line
@ 2009-02-12 8:21 Yann Simon
2009-02-18 17:01 ` Shawn O. Pearce
0 siblings, 1 reply; 7+ messages in thread
From: Yann Simon @ 2009-02-12 8:21 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
The previous implementation made the assumption that
the Signed-off-by is always on the last line.
Correct this assumption and deal with Signed-off-by everywhere in
the commit message.
Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
---
.../egit/ui/internal/dialogs/CommitDialog.java | 65
++++++++++++--------
1 files changed, 40 insertions(+), 25 deletions(-)
diff --git
a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
index bbe7193..403d69d 100644
---
a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
+++
b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
@@ -179,14 +179,16 @@ public void keyPressed(KeyEvent arg0) {
if (committer != null)
committerText.setText(committer);
committerText.addModifyListener(new ModifyListener() {
+ String oldCommitter = committerText.getText();
public void modifyText(ModifyEvent e) {
if (signedOffButton.getSelection()) {
// the commit message is signed
// the signature must be updated
- String oldCommitText = commitText.getText();
- oldCommitText = removeLastLine(oldCommitText);
- oldCommitText = signOff(oldCommitText);
- commitText.setText(oldCommitText);
+ String neuCommitter = committerText.getText();
+ String oldSignOff = getSignedOff(oldCommitter);
+ String neuSignOff = getSignedOff(neuCommitter);
+
commitText.setText(replaceSignOff(commitText.getText(), oldSignOff,
neuSignOff));
+ oldCommitter = neuCommitter;
}
}
});
@@ -230,12 +232,16 @@ public void widgetDefaultSelected(SelectionEvent
arg0) {
signedOffButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
+ String curText = commitText.getText();
if (signedOffButton.getSelection()) {
// add signed off line
- commitText.setText(signOff(commitText.getText()));
+ commitText.setText(signOff(curText));
} else {
// remove signed off line
-
commitText.setText(removeLastLine(commitText.getText()));
+ curText = replaceSignOff(curText, getSignedOff(), "");
+ if (curText.endsWith(Text.DELIMITER + Text.DELIMITER))
+ curText = curText.substring(0, curText.length()
- Text.DELIMITER.length());
+ commitText.setText(curText);
}
}
@@ -279,11 +285,19 @@ public void modifyText(ModifyEvent e) {
}
private void updateSignedOffButton() {
-
signedOffButton.setSelection(getLastLine(commitText.getText()).equals(getSignedOff()));
+ String curText = commitText.getText();
+ if (!curText.endsWith(Text.DELIMITER))
+ curText += Text.DELIMITER;
+
+ signedOffButton.setSelection(curText.indexOf(getSignedOff() +
Text.DELIMITER) != -1);
}
private String getSignedOff() {
- return Constants.SIGNED_OFF_BY_TAG + committerText.getText();
+ return getSignedOff(committerText.getText());
+ }
+
+ private String getSignedOff(String signer) {
+ return Constants.SIGNED_OFF_BY_TAG + signer;
}
private String signOff(String input) {
@@ -299,32 +313,33 @@ private String signOff(String input) {
}
private String getLastLine(String input) {
- String output = removeLastLineBreak(input);
+ String output = input;
int breakLength = Text.DELIMITER.length();
- // get the last line
+ // remove last line break if exist
int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
+ if (lastIndexOfLineBreak != -1 && lastIndexOfLineBreak ==
output.length() - breakLength)
+ output = output.substring(0, output.length() - breakLength);
+
+ // get the last line
+ lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
return lastIndexOfLineBreak == -1 ? output :
output.substring(lastIndexOfLineBreak + breakLength, output.length());
}
- private String removeLastLine(String input) {
- String output = removeLastLineBreak(input);
+ private String replaceSignOff(String input, String oldSignOff,
String newSignOff) {
+ assert input != null;
+ assert oldSignOff != null;
+ assert newSignOff != null;
- // remove the last line if possible
- int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
- return lastIndexOfLineBreak == -1 ? "" : output.substring(0,
lastIndexOfLineBreak); //$NON-NLS-1$
- }
-
- private String removeLastLineBreak(String input) {
- String output = input;
- int breakLength = Text.DELIMITER.length();
+ String curText = input;
+ if (!curText.endsWith(Text.DELIMITER))
+ curText += Text.DELIMITER;
- // remove last line break if exist
- int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
- if (lastIndexOfLineBreak != -1 && lastIndexOfLineBreak ==
output.length() - breakLength)
- output = output.substring(0, output.length() - breakLength);
+ int indexOfSignOff = curText.indexOf(oldSignOff + Text.DELIMITER);
+ if (indexOfSignOff == -1)
+ return input;
- return output;
+ return input.substring(0, indexOfSignOff) + newSignOff +
input.substring(indexOfSignOff + oldSignOff.length(), input.length());
}
private Menu getContextMenu() {
--
1.6.0.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line
2009-02-12 8:21 [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line Yann Simon
@ 2009-02-18 17:01 ` Shawn O. Pearce
0 siblings, 0 replies; 7+ messages in thread
From: Shawn O. Pearce @ 2009-02-18 17:01 UTC (permalink / raw)
To: Yann Simon; +Cc: Robin Rosenberg, git
Yann Simon <yann.simon.fr@gmail.com> wrote:
> The previous implementation made the assumption that
> the Signed-off-by is always on the last line.
>
> Correct this assumption and deal with Signed-off-by everywhere in
> the commit message.
>
> Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
> ---
> .../egit/ui/internal/dialogs/CommitDialog.java | 65
> ++++++++++++--------
> 1 files changed, 40 insertions(+), 25 deletions(-)
This patch is whitespace damaged and can't be applied by machine.
> diff --git
> a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
> b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
> index bbe7193..403d69d 100644
> ---
> a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
> +++
> b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
--
Shawn.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line
@ 2009-02-19 9:20 Yann Simon
2009-02-19 17:28 ` Robin Rosenberg
2009-02-19 17:53 ` Sverre Rabbelier
0 siblings, 2 replies; 7+ messages in thread
From: Yann Simon @ 2009-02-19 9:20 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
The previous implementation made the assumption that
the Signed-off-by is always on the last line.
Correct this assumption and deal with Signed-off-by everywhere in
the commit message.
Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
---
I hope this send will not be whitespace damaged.
--
yann
.../egit/ui/internal/dialogs/CommitDialog.java | 65
++++++++++++--------
1 files changed, 40 insertions(+), 25 deletions(-)
diff --git
a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
index bbe7193..403d69d 100644
---
a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
+++
b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
@@ -179,14 +179,16 @@ public void keyPressed(KeyEvent arg0) {
if (committer != null)
committerText.setText(committer);
committerText.addModifyListener(new ModifyListener() {
+ String oldCommitter = committerText.getText();
public void modifyText(ModifyEvent e) {
if (signedOffButton.getSelection()) {
// the commit message is signed
// the signature must be updated
- String oldCommitText = commitText.getText();
- oldCommitText = removeLastLine(oldCommitText);
- oldCommitText = signOff(oldCommitText);
- commitText.setText(oldCommitText);
+ String neuCommitter = committerText.getText();
+ String oldSignOff = getSignedOff(oldCommitter);
+ String neuSignOff = getSignedOff(neuCommitter);
+
commitText.setText(replaceSignOff(commitText.getText(), oldSignOff,
neuSignOff));
+ oldCommitter = neuCommitter;
}
}
});
@@ -230,12 +232,16 @@ public void widgetDefaultSelected(SelectionEvent
arg0) {
signedOffButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
+ String curText = commitText.getText();
if (signedOffButton.getSelection()) {
// add signed off line
- commitText.setText(signOff(commitText.getText()));
+ commitText.setText(signOff(curText));
} else {
// remove signed off line
-
commitText.setText(removeLastLine(commitText.getText()));
+ curText = replaceSignOff(curText, getSignedOff(), "");
+ if (curText.endsWith(Text.DELIMITER + Text.DELIMITER))
+ curText = curText.substring(0, curText.length()
- Text.DELIMITER.length());
+ commitText.setText(curText);
}
}
@@ -279,11 +285,19 @@ public void modifyText(ModifyEvent e) {
}
private void updateSignedOffButton() {
-
signedOffButton.setSelection(getLastLine(commitText.getText()).equals(getSignedOff()));
+ String curText = commitText.getText();
+ if (!curText.endsWith(Text.DELIMITER))
+ curText += Text.DELIMITER;
+
+ signedOffButton.setSelection(curText.indexOf(getSignedOff() +
Text.DELIMITER) != -1);
}
private String getSignedOff() {
- return Constants.SIGNED_OFF_BY_TAG + committerText.getText();
+ return getSignedOff(committerText.getText());
+ }
+
+ private String getSignedOff(String signer) {
+ return Constants.SIGNED_OFF_BY_TAG + signer;
}
private String signOff(String input) {
@@ -299,32 +313,33 @@ private String signOff(String input) {
}
private String getLastLine(String input) {
- String output = removeLastLineBreak(input);
+ String output = input;
int breakLength = Text.DELIMITER.length();
- // get the last line
+ // remove last line break if exist
int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
+ if (lastIndexOfLineBreak != -1 && lastIndexOfLineBreak ==
output.length() - breakLength)
+ output = output.substring(0, output.length() - breakLength);
+
+ // get the last line
+ lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
return lastIndexOfLineBreak == -1 ? output :
output.substring(lastIndexOfLineBreak + breakLength, output.length());
}
- private String removeLastLine(String input) {
- String output = removeLastLineBreak(input);
+ private String replaceSignOff(String input, String oldSignOff,
String newSignOff) {
+ assert input != null;
+ assert oldSignOff != null;
+ assert newSignOff != null;
- // remove the last line if possible
- int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
- return lastIndexOfLineBreak == -1 ? "" : output.substring(0,
lastIndexOfLineBreak); //$NON-NLS-1$
- }
-
- private String removeLastLineBreak(String input) {
- String output = input;
- int breakLength = Text.DELIMITER.length();
+ String curText = input;
+ if (!curText.endsWith(Text.DELIMITER))
+ curText += Text.DELIMITER;
- // remove last line break if exist
- int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
- if (lastIndexOfLineBreak != -1 && lastIndexOfLineBreak ==
output.length() - breakLength)
- output = output.substring(0, output.length() - breakLength);
+ int indexOfSignOff = curText.indexOf(oldSignOff + Text.DELIMITER);
+ if (indexOfSignOff == -1)
+ return input;
- return output;
+ return input.substring(0, indexOfSignOff) + newSignOff +
input.substring(indexOfSignOff + oldSignOff.length(), input.length());
}
private Menu getContextMenu() {
--
1.6.1.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line
2009-02-19 9:20 Yann Simon
@ 2009-02-19 17:28 ` Robin Rosenberg
2009-02-19 17:53 ` Sverre Rabbelier
1 sibling, 0 replies; 7+ messages in thread
From: Robin Rosenberg @ 2009-02-19 17:28 UTC (permalink / raw)
To: Yann Simon; +Cc: Shawn O. Pearce, git
Yann Simon <yann.simon.fr@gmail.com>writes:
> The previous implementation made the assumption that
> the Signed-off-by is always on the last line.
>
> Correct this assumption and deal with Signed-off-by everywhere in
> the commit message.
>
> Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
> ---
> I hope this send will not be whitespace damaged.
Sorry, It suffers from severe whitespace burns.
-- robin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line
2009-02-19 9:20 Yann Simon
2009-02-19 17:28 ` Robin Rosenberg
@ 2009-02-19 17:53 ` Sverre Rabbelier
2009-02-20 7:48 ` Yann Simon
1 sibling, 1 reply; 7+ messages in thread
From: Sverre Rabbelier @ 2009-02-19 17:53 UTC (permalink / raw)
To: Yann Simon; +Cc: Robin Rosenberg, Shawn O. Pearce, git
On Thu, Feb 19, 2009 at 10:20, Yann Simon <yann.simon.fr@gmail.com> wrote:
> I hope this send will not be whitespace damaged.
You could of course send your patch inlined, but attach the patch as
well if you fear your MUA will damage the patch. That way the patch
can still be easily reviewed, and can be applied just as well.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line
2009-02-19 17:53 ` Sverre Rabbelier
@ 2009-02-20 7:48 ` Yann Simon
0 siblings, 0 replies; 7+ messages in thread
From: Yann Simon @ 2009-02-20 7:48 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: Robin Rosenberg, Shawn O. Pearce, git
2009/2/19 Sverre Rabbelier <srabbelier@gmail.com>:
> On Thu, Feb 19, 2009 at 10:20, Yann Simon <yann.simon.fr@gmail.com> wrote:
>> I hope this send will not be whitespace damaged.
>
> You could of course send your patch inlined, but attach the patch as
> well if you fear your MUA will damage the patch. That way the patch
> can still be easily reviewed, and can be applied just as well.
>
> --
> Cheers,
>
> Sverre Rabbelier
>
I switched from STMP to IMAP.
Maybe it is the problem.
I will revert to SMTP and re-test the send.
Sorry for the trouble
Yann
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line
@ 2009-02-20 8:09 Yann Simon
0 siblings, 0 replies; 7+ messages in thread
From: Yann Simon @ 2009-02-20 8:09 UTC (permalink / raw)
To: Robin Rosenberg, Shawn O. Pearce; +Cc: git
The previous implementation made the assumption that
the Signed-off-by is always on the last line.
Correct this assumption and deal with Signed-off-by everywhere in
the commit message.
Signed-off-by: Yann Simon <yann.simon.fr@gmail.com>
---
I found the problem with whitespace corruptions.
yann
.../egit/ui/internal/dialogs/CommitDialog.java | 65 ++++++++++++--------
1 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
index bbe7193..403d69d 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/dialogs/CommitDialog.java
@@ -179,14 +179,16 @@ public void keyPressed(KeyEvent arg0) {
if (committer != null)
committerText.setText(committer);
committerText.addModifyListener(new ModifyListener() {
+ String oldCommitter = committerText.getText();
public void modifyText(ModifyEvent e) {
if (signedOffButton.getSelection()) {
// the commit message is signed
// the signature must be updated
- String oldCommitText = commitText.getText();
- oldCommitText = removeLastLine(oldCommitText);
- oldCommitText = signOff(oldCommitText);
- commitText.setText(oldCommitText);
+ String neuCommitter = committerText.getText();
+ String oldSignOff = getSignedOff(oldCommitter);
+ String neuSignOff = getSignedOff(neuCommitter);
+ commitText.setText(replaceSignOff(commitText.getText(), oldSignOff, neuSignOff));
+ oldCommitter = neuCommitter;
}
}
});
@@ -230,12 +232,16 @@ public void widgetDefaultSelected(SelectionEvent arg0) {
signedOffButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent arg0) {
+ String curText = commitText.getText();
if (signedOffButton.getSelection()) {
// add signed off line
- commitText.setText(signOff(commitText.getText()));
+ commitText.setText(signOff(curText));
} else {
// remove signed off line
- commitText.setText(removeLastLine(commitText.getText()));
+ curText = replaceSignOff(curText, getSignedOff(), "");
+ if (curText.endsWith(Text.DELIMITER + Text.DELIMITER))
+ curText = curText.substring(0, curText.length() - Text.DELIMITER.length());
+ commitText.setText(curText);
}
}
@@ -279,11 +285,19 @@ public void modifyText(ModifyEvent e) {
}
private void updateSignedOffButton() {
- signedOffButton.setSelection(getLastLine(commitText.getText()).equals(getSignedOff()));
+ String curText = commitText.getText();
+ if (!curText.endsWith(Text.DELIMITER))
+ curText += Text.DELIMITER;
+
+ signedOffButton.setSelection(curText.indexOf(getSignedOff() + Text.DELIMITER) != -1);
}
private String getSignedOff() {
- return Constants.SIGNED_OFF_BY_TAG + committerText.getText();
+ return getSignedOff(committerText.getText());
+ }
+
+ private String getSignedOff(String signer) {
+ return Constants.SIGNED_OFF_BY_TAG + signer;
}
private String signOff(String input) {
@@ -299,32 +313,33 @@ private String signOff(String input) {
}
private String getLastLine(String input) {
- String output = removeLastLineBreak(input);
+ String output = input;
int breakLength = Text.DELIMITER.length();
- // get the last line
+ // remove last line break if exist
int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
+ if (lastIndexOfLineBreak != -1 && lastIndexOfLineBreak == output.length() - breakLength)
+ output = output.substring(0, output.length() - breakLength);
+
+ // get the last line
+ lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
return lastIndexOfLineBreak == -1 ? output : output.substring(lastIndexOfLineBreak + breakLength, output.length());
}
- private String removeLastLine(String input) {
- String output = removeLastLineBreak(input);
+ private String replaceSignOff(String input, String oldSignOff, String newSignOff) {
+ assert input != null;
+ assert oldSignOff != null;
+ assert newSignOff != null;
- // remove the last line if possible
- int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
- return lastIndexOfLineBreak == -1 ? "" : output.substring(0, lastIndexOfLineBreak); //$NON-NLS-1$
- }
-
- private String removeLastLineBreak(String input) {
- String output = input;
- int breakLength = Text.DELIMITER.length();
+ String curText = input;
+ if (!curText.endsWith(Text.DELIMITER))
+ curText += Text.DELIMITER;
- // remove last line break if exist
- int lastIndexOfLineBreak = output.lastIndexOf(Text.DELIMITER);
- if (lastIndexOfLineBreak != -1 && lastIndexOfLineBreak == output.length() - breakLength)
- output = output.substring(0, output.length() - breakLength);
+ int indexOfSignOff = curText.indexOf(oldSignOff + Text.DELIMITER);
+ if (indexOfSignOff == -1)
+ return input;
- return output;
+ return input.substring(0, indexOfSignOff) + newSignOff + input.substring(indexOfSignOff + oldSignOff.length(), input.length());
}
private Menu getContextMenu() {
--
1.6.1.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-02-20 8:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-12 8:21 [PATCH JGIT] In the commit dialog, deal with Signed-off-by not on the last line Yann Simon
2009-02-18 17:01 ` Shawn O. Pearce
-- strict thread matches above, loose matches on Subject: below --
2009-02-19 9:20 Yann Simon
2009-02-19 17:28 ` Robin Rosenberg
2009-02-19 17:53 ` Sverre Rabbelier
2009-02-20 7:48 ` Yann Simon
2009-02-20 8:09 Yann Simon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).