Package org.eclipse.jgit.lib
Class CommitConfig
java.lang.Object
org.eclipse.jgit.lib.CommitConfig
The standard "commit" configuration parameters.
- Since:
- 5.13
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow to clean up commit messages when committing. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate CommitConfig.CleanupModeprivate Stringprivate static final Stringprivate static final Charsetprivate Stringstatic final Config.SectionParser<CommitConfig>Key forConfig.get(SectionParser). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcleanText(String text, CommitConfig.CleanupMode mode, char commentChar) Processes a text according to the givenCommitConfig.CleanupMode.Retrieves theCommitConfig.CleanupModeas given by git configcommit.cleanup.Get the encoding of the commit as defined in the giti18n.commitEncodingproperty.getCommitTemplateContent(Repository repository) Get the content to the commit template as defined incommit.template.Get the path to the commit template as defined in the gitcommit.templateproperty.private Charsetprivate static booleanresolve(CommitConfig.CleanupMode mode, boolean defaultStrip) Computes a non-defaultCommitConfig.CleanupModefrom the given mode and the git config.
-
Field Details
-
KEY
Key forConfig.get(SectionParser). -
CUT
- See Also:
-
DEFAULT_COMMIT_MESSAGE_ENCODING
-
i18nCommitEncoding
-
commitTemplatePath
-
cleanupMode
-
-
Constructor Details
-
CommitConfig
-
-
Method Details
-
getCommitTemplatePath
Get the path to the commit template as defined in the gitcommit.templateproperty.- Returns:
- the path to commit template or
nullif not present.
-
getCommitEncoding
Get the encoding of the commit as defined in the giti18n.commitEncodingproperty.- Returns:
- the encoding or
nullif not present.
-
getCleanupMode
Retrieves theCommitConfig.CleanupModeas given by git configcommit.cleanup.- Returns:
- the
CommitConfig.CleanupMode;CommitConfig.CleanupMode.DEFAULTif the git config is not set - Since:
- 6.1
-
resolve
@NonNull public CommitConfig.CleanupMode resolve(@NonNull CommitConfig.CleanupMode mode, boolean defaultStrip) Computes a non-defaultCommitConfig.CleanupModefrom the given mode and the git config.- Parameters:
mode-CommitConfig.CleanupModeto resolvedefaultStrip- iftruereturnCommitConfig.CleanupMode.STRIPif the git config is also "default", otherwise returnCommitConfig.CleanupMode.WHITESPACE- Returns:
- the
mode, if it is notCommitConfig.CleanupMode.DEFAULT, otherwise the resolved mode, which is neverCommitConfig.CleanupMode.DEFAULT - Since:
- 6.1
-
getCommitTemplateContent
@Nullable public String getCommitTemplateContent(@NonNull Repository repository) throws FileNotFoundException, IOException, ConfigInvalidException Get the content to the commit template as defined incommit.template. If noi18n.commitEncodingis specified, UTF-8 fallback is used.- Parameters:
repository- to resolve relative path in local git repo config- Returns:
- content of the commit template or
nullif not present. - Throws:
IOException- if the template file can not be readFileNotFoundException- if the template file does not existsConfigInvalidException- if acommitEncodingis specified and is invalid- Since:
- 6.0
-
getEncoding
- Throws:
ConfigInvalidException
-
cleanText
public static String cleanText(@NonNull String text, @NonNull CommitConfig.CleanupMode mode, char commentChar) Processes a text according to the givenCommitConfig.CleanupMode.- Parameters:
text- text to processmode-CommitConfig.CleanupModeto usecommentChar- comment character (normally#) to use ifmodeisCommitConfig.CleanupMode.STRIPorCommitConfig.CleanupMode.SCISSORS- Returns:
- the processed text
- Throws:
IllegalArgumentException- ifmodeisCommitConfig.CleanupMode.DEFAULT(useresolve(CleanupMode, boolean)first)- Since:
- 6.1
-
isComment
-