Class DescribeResult


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

      Constructors 
      Constructor Description
      DescribeResult​(java.lang.String tagName)  
      DescribeResult​(java.lang.String tagName, boolean dirty, java.util.Optional<java.lang.String> dirtyMarker)  
      DescribeResult​(org.eclipse.jgit.lib.ObjectReader objectReader, java.lang.String tagName, int commitsAwayFromTag, org.eclipse.jgit.lib.ObjectId commitId)  
      DescribeResult​(org.eclipse.jgit.lib.ObjectReader objectReader, java.lang.String tagName, int commitsAwayFromTag, org.eclipse.jgit.lib.ObjectId commitId, boolean dirty, java.lang.String dirtyMarker)  
      DescribeResult​(org.eclipse.jgit.lib.ObjectReader objectReader, java.lang.String tagName, int commitsAwayFromTag, org.eclipse.jgit.lib.ObjectId commitId, boolean dirty, java.util.Optional<java.lang.String> dirtyMarker, boolean forceLongFormat)  
      DescribeResult​(org.eclipse.jgit.lib.ObjectReader objectReader, org.eclipse.jgit.lib.ObjectId commitId)  
      DescribeResult​(org.eclipse.jgit.lib.ObjectReader objectReader, org.eclipse.jgit.lib.ObjectId commitId, boolean dirty, java.util.Optional<java.lang.String> dirtyMarker)  
    • Constructor Detail

      • DescribeResult

        public DescribeResult​(@Nonnull
                              java.lang.String tagName)
      • DescribeResult

        public DescribeResult​(@Nonnull
                              org.eclipse.jgit.lib.ObjectReader objectReader,
                              java.lang.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,
                              java.lang.String tagName,
                              int commitsAwayFromTag,
                              org.eclipse.jgit.lib.ObjectId commitId,
                              boolean dirty,
                              java.lang.String dirtyMarker)
      • DescribeResult

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

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

        public DescribeResult​(@Nonnull
                              java.lang.String tagName,
                              boolean dirty,
                              @Nonnull
                              java.util.Optional<java.lang.String> dirtyMarker)
    • Method Detail

      • withCommitIdAbbrev

        @Nonnull
        public DescribeResult withCommitIdAbbrev​(int n)
      • toString

        public java.lang.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 java.lang.Object
        Returns:
        the String representation of this Describe command
      • commitsAwayFromTag

        @Nullable
        public java.lang.String commitsAwayFromTag()
      • dirtyMarker

        @Nullable
        public java.lang.String dirtyMarker()
      • prefixedCommitId

        @Nullable
        public java.lang.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 java.lang.String tag()