Class GitCommitsRecord

java.lang.Object
io.jenkins.plugins.forensics.git.reference.GitCommitsRecord
All Implemented Interfaces:
Action, ModelObject, Serializable, RunAction2

public class GitCommitsRecord extends Object implements RunAction2, Serializable
Stores all the commits for a given build and provides a link to the latest commit. For each SCM repository a unique GitCommitsRecord instance will be used.
Author:
Arne Schöntag
See Also:
  • Method Details

    • findRecordForScm

      public static Optional<GitCommitsRecord> findRecordForScm(Run<?,?> build, String scmKey)
      Tries to find a GitCommitsRecord for the specified SCM.
      Parameters:
      build - the build to search for corresponding GitCommitsRecord actions
      scmKey - the ID of the SCM repository
      Returns:
      the record with the commits if found, Optional.empty() otherwise
    • getOwner

      public Run<?,?> getOwner()
    • isFirstBuild

      public boolean isFirstBuild()
    • getScmKey

      public String getScmKey()
    • getLatestCommit

      public String getLatestCommit()
    • getLatestCommitLink

      public String getLatestCommitLink()
    • getTargetParentCommit

      public String getTargetParentCommit()
    • hasTargetParentCommit

      public boolean hasTargetParentCommit()
      Determines if the commits contain a merge commit with the target branch.
      Returns:
      true if the commits contain a merge commit with the target branch
    • getErrorMessages

      public List<String> getErrorMessages()
    • getInfoMessages

      public List<String> getInfoMessages()
    • size

      public int size()
      Returns the number of new commits.
      Returns:
      the number of new commits
    • getSize

      public int getSize()
    • isNotEmpty

      public boolean isNotEmpty()
    • isEmpty

      public boolean isEmpty()
    • getCommits

      public List<String> getCommits()
    • getCommitsWithMerge

      public List<String> getCommitsWithMerge()
      Returns all recorded new commits including the commits which belong to a merge, if it is part of this commit record. These affected merge commits consist of the latest commit of the target branch as well as the latest merge commit itself. The order is as follows:
      1. Latest merge commit
      2. Latest target branch commit
      3. Recorded new commits
      Returns:
      the hash codes of the found commits
    • contains

      public boolean contains(String commit)
      Returns true if the specified commit is part of the commits.
      Parameters:
      commit - the commit to search for
      Returns:
      true if the commits contain the specified commit, false otherwise
    • onAttached

      public void onAttached(Run<?,?> run)
      Specified by:
      onAttached in interface RunAction2
    • onLoad

      public void onLoad(Run<?,?> run)
      Specified by:
      onLoad in interface RunAction2
    • getIconFileName

      public String getIconFileName()
      Specified by:
      getIconFileName in interface Action
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface Action
      Specified by:
      getDisplayName in interface ModelObject
    • getUrlName

      public String getUrlName()
      Specified by:
      getUrlName in interface Action
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getReferencePoint

      public Optional<Run<?,?>> getReferencePoint(GitCommitsRecord referenceCommits, int maxCommits, boolean skipUnknownCommits)
      Tries to find a reference build using the specified GitCommitsRecord of the reference job as a starting point.
      Parameters:
      referenceCommits - the recorded commits of the build of the reference job that should be used as a starting point for the search
      maxCommits - maximal number of commits to look at
      skipUnknownCommits - determines whether a build with unknown commits should be skipped or not
      Returns:
      the found reference build or empty if none has been found