Class DescribeResult

java.lang.Object
pl.project13.core.jgit.DescribeResult

public class DescribeResult extends Object
Represents the result of a git describe command. See toString() for a detailed information how this result looks like.
  • Field Details

  • Constructor Details

    • DescribeResult

      public DescribeResult(@Nonnull String tagName)
    • DescribeResult

      public DescribeResult(@Nonnull org.eclipse.jgit.lib.ObjectReader objectReader, String tagName, int commitsAwayFromTag, @Nonnull org.eclipse.jgit.lib.ObjectId commitId)
    • DescribeResult

      public DescribeResult(@Nonnull org.eclipse.jgit.lib.ObjectReader objectReader, @Nonnull org.eclipse.jgit.lib.ObjectId commitId)
    • DescribeResult

      public DescribeResult(@Nonnull org.eclipse.jgit.lib.ObjectReader objectReader, String tagName, int commitsAwayFromTag, org.eclipse.jgit.lib.ObjectId commitId, boolean dirty, String dirtyMarker)
    • DescribeResult

      public DescribeResult(@Nonnull org.eclipse.jgit.lib.ObjectReader objectReader, String tagName, int commitsAwayFromTag, org.eclipse.jgit.lib.ObjectId commitId, boolean dirty, Optional<String> dirtyMarker, boolean forceLongFormat)
    • DescribeResult

      public DescribeResult(@Nonnull org.eclipse.jgit.lib.ObjectReader objectReader, @Nonnull org.eclipse.jgit.lib.ObjectId commitId, boolean dirty, @Nonnull Optional<String> dirtyMarker)
    • DescribeResult

      public DescribeResult(@Nonnull String tagName, boolean dirty, @Nonnull Optional<String> dirtyMarker)
  • Method Details

    • withCommitIdAbbrev

      @Nonnull public DescribeResult withCommitIdAbbrev(int n)
    • toString

      public String toString()
      The format of a describe result is defined as:
       v1.0.4-14-g2414721-DEV
         ^    ^    ^       ^
         |    |    |       |-- if a dirtyMarker was given, it will appear here if the repository is in "dirty" state
         |    |    |---------- the "g" prefixed commit id. The prefix is compatible with what git-describe would return - weird, but true.
         |    |--------------- the number of commits away from the found tag. So "2414721" is 14 commits ahead of "v1.0.4", in this example.
         |-------------------- the "nearest" tag, to the mentioned commit.
       
      Other outputs may look like:
       v1.0.4 -- if the repository is "on a tag"
       v1.0.4-DEV -- if the repository is "on a tag", but in "dirty" state
       2414721 -- a plain commit id hash if not tags were defined (of determined "near" this commit).
                  It does NOT include the "g" prefix, that is used in the "full" describe output format!
       
      For more details (on when what output will be returned etc), see man git-describe. In general, you can assume it's a "best effort" approach, to give you as much info about the repo state as possible.
      Overrides:
      toString in class Object
      Returns:
      the String representation of this Describe command
    • commitsAwayFromTag

      @Nullable public String commitsAwayFromTag()
    • dirtyMarker

      @Nullable public String dirtyMarker()
    • prefixedCommitId

      @Nullable public String prefixedCommitId()

      The (possibly) "g" prefixed abbreviated object id of a commit.

      The "g" prefix is prepended to be compatible with git's describe output, please refer to man git-describe to check why it's included.

      The "g" prefix is used when a tag is defined on this result. If it's not, this method yields a plain commit id hash. This is following git's behaviour - so any git tooling should be happy with this output.

      Notes about the abbreviated object id: Git will try to use your given abbrev length, but when it's too short to guarantee uniqueness - a longer one will be used (which WILL guarantee uniqueness). If you need the full commit id, it's always available via commitObjectId().

      Returns:
      The (possibly) "g" prefixed abbreviated object id of a commit.
    • commitObjectId

      @Nullable public org.eclipse.jgit.lib.ObjectId commitObjectId()
    • tag

      @Nullable public String tag()