Class GitChangelogApi

java.lang.Object
se.bjurr.gitchangelog.api.GitChangelogApi

public final class GitChangelogApi extends Object
  • Method Details

    • gitChangelogApiBuilder

      public static GitChangelogApi gitChangelogApiBuilder()
    • getChangelog

      public Changelog getChangelog() throws GitChangelogRepositoryException
      Get the changelog as data object.
      Throws:
      GitChangelogRepositoryException
    • getSettings

      public Settings getSettings()
    • render

      public void render(Writer writer, boolean prepend) throws GitChangelogRepositoryException
      Get the changelog.
      Parameters:
      prepend -
      Throws:
      GitChangelogRepositoryException
    • getTemplateString

      public String getTemplateString()
    • getTemplateString

      public String getTemplateString(boolean prepend)
    • render

      public String render() throws GitChangelogRepositoryException
      Get the changelog.
      Throws:
      GitChangelogRepositoryException
    • render

      public String render(boolean prepend) throws GitChangelogRepositoryException
      Get the changelog. There is a different default changelog when prepending which is why it can be supplied
      Throws:
      GitChangelogRepositoryException
    • toFile

      public void toFile(File file) throws GitChangelogRepositoryException, IOException
      Write changelog to file.
      Throws:
      GitChangelogRepositoryException
      IOException - When file cannot be written.
    • prependToFile

      public void prependToFile(File file) throws GitChangelogRepositoryException, IOException
      Prepend the changelog to the given file.
      Throws:
      GitChangelogRepositoryException
      IOException
    • getNextSemanticVersion

      public SemanticVersion getNextSemanticVersion() throws GitChangelogRepositoryException
      Get next semantic version. This requires version-pattern and major/minor/patch patterns to have been configured.
      Throws:
      GitChangelogRepositoryException
    • getHighestSemanticVersion

      public SemanticVersion getHighestSemanticVersion() throws GitChangelogRepositoryException
      Throws:
      GitChangelogRepositoryException
    • getCurrentSemanticVersion

      public SemanticVersion getCurrentSemanticVersion() throws Exception
      Throws:
      Exception
    • withSemanticMajorVersionPattern

      public GitChangelogApi withSemanticMajorVersionPattern(String major) throws GitChangelogRepositoryException
      Will be used to determine next semantic version.
      Throws:
      GitChangelogRepositoryException
    • withSemanticMinorVersionPattern

      public GitChangelogApi withSemanticMinorVersionPattern(String minor) throws GitChangelogRepositoryException
      Will be used to determine next semantic version.
      Throws:
      GitChangelogRepositoryException
    • withSemanticPatchVersionPattern

      public GitChangelogApi withSemanticPatchVersionPattern(String patch) throws GitChangelogRepositoryException
      Will be used to determine next semantic version.
      Throws:
      GitChangelogRepositoryException
    • withHandlebarsHelper

      public GitChangelogApi withHandlebarsHelper(String javascriptHelper) throws GitChangelogRepositoryException, IOException
      Registers (Javscript) Handlebars helper to use in template.
      Throws:
      GitChangelogRepositoryException
      IOException
    • withHandlebarsHelper

      public GitChangelogApi withHandlebarsHelper(String name, com.github.jknack.handlebars.Helper<?> helper) throws GitChangelogRepositoryException, IOException
      Registers (Java) Handlebars helper to use in template.
      Returns:
      Throws:
      GitChangelogRepositoryException
      IOException
    • withCustomIssue

      public GitChangelogApi withCustomIssue(String name, String pattern, String link, String title)
      Custom issues are added to support any kind of issue management, perhaps something that is internal to your project. See SettingsIssue.
    • withDateFormat

      public GitChangelogApi withDateFormat(String dateFormat)
      Format of dates, see SimpleDateFormat.
    • withExtendedVariables

      public GitChangelogApi withExtendedVariables(Map<String,Object> extendedVariables)
      Extended variables is simply a key-value mapping of variables that are made available in the template. Is used, for example, by the Bitbucket plugin to supply some internal variables to the changelog context.
    • withExtendedHeaders

      public GitChangelogApi withExtendedHeaders(Map<String,String> extendedHeaders)
      Extended headers is simply a key-value mapping of headers that will be passed to REST request. Is used, for example, to bypass 2-factor authentication.
    • withFromRevision

      public GitChangelogApi withFromRevision(String revision, InclusivenessStrategy strategy)
      Include all commits from here. Any tag or branch name or commit hash. There is a constant pointing at the first commit here: reference{GitChangelogApiConstants#ZERO_COMMIT}.
    • withFromRevision

      public GitChangelogApi withFromRevision(String fromRevision)
      Include all commits from here. Any tag or branch name or commit hash. There is a constant pointing at the first commit here: reference{GitChangelogApiConstants#ZERO_COMMIT}.
    • withFromCommit

      @Deprecated public GitChangelogApi withFromCommit(String fromCommit)
      Deprecated.
      Include all commits from here. Any commit hash. There is a constant pointing at the first commit here: reference{GitChangelogApiConstants#ZERO_COMMIT}.
    • withFromRef

      @Deprecated public GitChangelogApi withFromRef(String fromBranch)
      Deprecated.
      Include all commits from here. Any tag or branch name.
    • withFromRepo

      public GitChangelogApi withFromRepo(String fromRepo)
      Folder where repo lives.
    • withFromRepo

      public GitChangelogApi withFromRepo(File fromRepo)
    • withGitHubApi

      public GitChangelogApi withGitHubApi(String gitHubApi)
      URL pointing at GitHub API. When configured, the Issue.getTitle() will be populated with title from GitHub.
      https://api.github.com/repos/tomasbjerre/git-changelog-lib
    • withGitHubIssuePattern

      public GitChangelogApi withGitHubIssuePattern(String gitHubIssuePattern)
      Pattern to recognize GitHub:s. #([0-9]+)
    • withGitHubToken

      public GitChangelogApi withGitHubToken(String gitHubToken)
      GitHub authentication token. Configure to avoid low rate limits imposed by GitHub in case you have a lot of issues and/or pull requests.

      You can get one like this:
      curl -u 'yourgithubuser' -d '{"note":"Git Changelog Lib"}' https://api.github.com/authorizations
    • withGitLabIssuePattern

      public GitChangelogApi withGitLabIssuePattern(String gitLabIssuePattern)
      Pattern to recognize GitHub:s. #([0-9]+)
    • withGitLabProjectName

      public GitChangelogApi withGitLabProjectName(String gitLabProjectName)
      In this URL: https://gitlab.com/tomas.bjerre85/violations-test/issues it would be violations-test.
    • withGitLabServer

      public GitChangelogApi withGitLabServer(String gitLabServer)
      Example: https://gitlab.com/
    • withGitLabToken

      public GitChangelogApi withGitLabToken(String gitLabToken)
      You can create it in the project settings page.
    • withIgnoreCommitsWithMessage

      public GitChangelogApi withIgnoreCommitsWithMessage(String ignoreCommitsIfMessageMatches)
      A regular expression that is evaluated on the commit message of each commit. If it matches, the commit will be filtered out and not included in the changelog.

      To ignore tags creted by Maven and Gradle release plugins, perhaps you want this:
      ^\[maven-release-plugin\].*|^\[Gradle Release Plugin\].*|^Merge.*

      Remember to escape it, if added to the json-file it would look like this:
      ^\\[maven-release-plugin\\].*|^\\[Gradle Release Plugin\\].*|^Merge.*
    • withIgnoreCommitsOlderThan

      public GitChangelogApi withIgnoreCommitsOlderThan(Date ignoreCommitsIfOlderThan)
      A date that is evaluated on the author date of each commit. If the commit is older than the point in time given, then it will be filtered out and not included in the changelog.
      See SimpleDateFormat.
    • withIgnoreCommitsWithoutIssue

      public GitChangelogApi withIgnoreCommitsWithoutIssue(boolean ignoreCommitsWithoutIssue)
      If a commit cannot be mapped to any issue, it can be added to the virtual " no issue"-issue.

      True means that this issue will be created and populated.

      False means that it will not be created and commits that cannot be mapped to any issue will not be included in the changelog.
    • withIgnoreTagsIfNameMatches

      public GitChangelogApi withIgnoreTagsIfNameMatches(String ignoreTagsIfNameMatches)
      A regular expression that is evaluated on each tag. If it matches, the tag will be filtered out and not included in the changelog.
    • withJiraIssuePattern

      public GitChangelogApi withJiraIssuePattern(String jiraIssuePattern)
      Pattern to recognize JIRA:s. \b[a-zA-Z]([a-zA-Z]+)-([0-9]+)\b

      Or escaped if added to json-file:
      \\b[a-zA-Z]([a-zA-Z]+)-([0-9]+)\\b
    • withJiraPassword

      public GitChangelogApi withJiraPassword(String string)
      Authenticate to JIRA.
    • withJiraBasicAuthString

      public GitChangelogApi withJiraBasicAuthString(String string)
      Authenticate to JIRA.
    • withJiraBearer

      public GitChangelogApi withJiraBearer(String string)
      Authenticate to JIRA.
    • withJiraServer

      public GitChangelogApi withJiraServer(String jiraServer)
      URL pointing at your JIRA server. When configured, the Issue.getTitle() will be populated with title from JIRA.
      https://jiraserver/jira
    • withJiraUsername

      public GitChangelogApi withJiraUsername(String string)
      Authenticate to JIRA.
    • withRedmineIssuePattern

      public GitChangelogApi withRedmineIssuePattern(String redmineIssuePattern)
      Pattern to recognize Redmine:s. #([0-9]+)
    • withRedminePassword

      public GitChangelogApi withRedminePassword(String string)
      Authenticate to Redmine.
    • withRedmineToken

      public GitChangelogApi withRedmineToken(String string)
      Authenticate to Redmine with API_KEY
    • withRedmineServer

      public GitChangelogApi withRedmineServer(String redmineServer)
      URL pointing at your Redmine server. When configured, the Issue.getTitle() will be populated with title from Redmine.
      https://redmineserver/
    • withRedmineUsername

      public GitChangelogApi withRedmineUsername(String string)
      Authenticate to Redmine.
    • withJiraIssueAdditionalField

      public GitChangelogApi withJiraIssueAdditionalField(String field)
      Additional Fields for Jira. When configured, we will return from Jira the results of these fields, if they exist.
      "customfield_10000"

      /rest/api/2/issue/JIR-1234?fields=parent,summary,issuetype,labels,description,issuelinks,customfield_10000
    • withNoIssueName

      public GitChangelogApi withNoIssueName(String noIssueName)
      This is a "virtual issue" that is added to Changelog.getIssues(). It contains all commits that has no issue in the commit comment. This could be used as a "wall of shame" listing commiters that did not tag there commits with an issue.
    • withReadableTagName

      public GitChangelogApi withReadableTagName(String readableTagName)
      Your tags may look something like git-changelog-maven-plugin-1.6. But in the changelog you just want 1.6. With this regular expression, the numbering can be extracted from the tag name.
      /([^/]+?)$
    • withRemoveIssueFromMessageArgument

      public GitChangelogApi withRemoveIssueFromMessageArgument(boolean removeIssueFromMessage)
      If true, the changelog will not contain the issue in the commit comment. If your changelog is grouped by issues, you may want this to be true. If not grouped by issue, perhaps false.
    • withSettings

      public GitChangelogApi withSettings(URL url)
    • withTemplateContent

      public GitChangelogApi withTemplateContent(String templateContent)
      Use string as template. withTemplatePath(java.lang.String).
    • withTemplatePath

      public GitChangelogApi withTemplatePath(String templatePath)
      Path of template-file to use. It is a Mustache (https://mustache.github.io/) template. Supplied with the context of Changelog.
    • withPrependTemplatePath

      public GitChangelogApi withPrependTemplatePath(String templatePath)
      Path of template-file to use when prepending. It is a Mustache (https://mustache.github.io/) template. Supplied with the context of Changelog.
    • withTemplateBaseDir

      public GitChangelogApi withTemplateBaseDir(String templateBaseDir)
      Path to the base directory for template partial files
    • withTemplateSuffix

      public GitChangelogApi withTemplateSuffix(String templateSuffix)
      Suffix of the template partial files
    • withUseIntegrations

      public GitChangelogApi withUseIntegrations(boolean useIntegrations)
    • withTimeZone

      public GitChangelogApi withTimeZone(String timeZone)
      When date of commits are translated to a string, this timezone is used.
      UTC
    • withToRevision

      public GitChangelogApi withToRevision(String revision, InclusivenessStrategy strategy)
      Include all commits to this revision. Any tag or branch name or commit hash. There is a constant for master here: reference{GitChangelogApiConstants#REF_MASTER}.
    • withToRevision

      public GitChangelogApi withToRevision(String toRevision)
      Include all commits to this revision. Any tag or branch name or commit hash. There is a constant for master here: reference{GitChangelogApiConstants#REF_MASTER}.
    • withToCommit

      @Deprecated public GitChangelogApi withToCommit(String toCommit)
      Deprecated.
      Include all commits to here. Any commit hash.
    • withToRef

      @Deprecated public GitChangelogApi withToRef(String toBranch)
      Deprecated.
      Include all commits to this reference. Any tag or branch name. There is a constant for master here: reference{GitChangelogApiConstants#REF_MASTER}.
    • withPathFilters

      public GitChangelogApi withPathFilters(String... pathFilters)
      Filter commits using the provided path filters, analogous to using the cli command git log -- git log ...
      Parameters:
      pathFilters - the path filters to be used for filtering.
    • withUntaggedName

      public GitChangelogApi withUntaggedName(String untaggedName)
      Some commits may not be included in any tag. Commits that not released yet may not be tagged. This is a "virtual tag", added to Changelog.getTags(), that includes those commits. A fitting value may be "Next release".
    • withJiraEnabled

      public GitChangelogApi withJiraEnabled(boolean b)
    • withGitLabEnabled

      public GitChangelogApi withGitLabEnabled(boolean b)
    • withGitHubEnabled

      public GitChangelogApi withGitHubEnabled(boolean b)
    • withRedmineEnabled

      public GitChangelogApi withRedmineEnabled(boolean b)
    • withEncoding

      public GitChangelogApi withEncoding(Charset encoding)