From e9031bc5ff61afeac64cdfc4009c034949fd20e8 Mon Sep 17 00:00:00 2001 From: Markus Duft Date: Mon, 19 Mar 2012 08:18:39 +0100 Subject: Properly filter EGit generated contents from commit message Currently, the staging view falsely determines whether the user entered a commit message, as it sees its own generated contents. Change-Id: If14bc5d9d25911b9962e467482f07a659be8dd85 --- .../egit/ui/internal/staging/StagingView.java | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java index 2a0da03131..a5273f5516 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java @@ -82,6 +82,7 @@ import org.eclipse.jgit.api.errors.NoFilepatternException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEditor; import org.eclipse.jgit.dircache.DirCacheEntry; +import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; @@ -1121,9 +1122,33 @@ public class StagingView extends ViewPart { private boolean userEnteredCommmitMessage() { if (commitMessageComponent.getRepository() == null) return false; - String message = commitMessageComponent.getCommitMessage(); + String message = commitMessageComponent.getCommitMessage().replace( + UIText.StagingView_headCommitChanged, ""); //$NON-NLS-1$ if (message == null || message.trim().length() == 0) return false; + + String chIdLine = "Change-Id: I" + ObjectId.zeroId().name(); //$NON-NLS-1$ + + if (currentRepository.getConfig().getBoolean( + ConfigConstants.CONFIG_GERRIT_SECTION, + ConfigConstants.CONFIG_KEY_CREATECHANGEID, false) + && commitMessageComponent.getCreateChangeId()) { + if (message.trim().equals(chIdLine)) + return false; + + // change id was added automatically, but ther is more in the + // message; strip the id, and check for the signed-off-by tag + message = message.replace(chIdLine, ""); //$NON-NLS-1$ + } + + if (org.eclipse.egit.ui.Activator.getDefault().getPreferenceStore() + .getBoolean(UIPreferences.COMMIT_DIALOG_SIGNED_OFF_BY) + && commitMessageComponent.isSignedOff() + && message.trim().equals( + Constants.SIGNED_OFF_BY_TAG + + commitMessageComponent.getCommitter())) + return false; + return true; } -- cgit v1.2.3