Class VersionControlSystem

  • All Implemented Interfaces:
    org.ossreviewtoolkit.utils.common.Plugin

    
    public abstract class VersionControlSystem
     implements Plugin
                        
    • Constructor Detail

      • VersionControlSystem

        VersionControlSystem(CommandLineTool commandLineTool)
    • Method Detail

      • getVersion

         abstract String getVersion()

        Return the VCS command's version string, or an empty string if the version cannot be determined.

      • getDefaultBranchName

         abstract String getDefaultBranchName(String url)

        Return the name of the default branch for the repository at url. It is expected that there always is a default branch name that implementations can fall back to, and that the returned name is non-empty.

      • isApplicableUrl

         final Boolean isApplicableUrl(String vcsUrl)

        Return true if this VersionControlSystem can be used to download from the provided vcsUrl. First, try to find this out by only parsing the URL, but as a fallback implementations may actually probe the URL and make a network request.

      • download

         final WorkingTree download(Package pkg, File targetDir, Boolean allowMovingRevisions, Boolean recursive)

        Download the source code as specified by the pkg information to targetDir. allowMovingRevisions toggles whether to allow downloads using symbolic names that point to moving revisions, like Git branches. If recursive is true, any nested repositories (like Git submodules or Mercurial subrepositories) are downloaded, too.

        Returns:

        An object describing the downloaded working tree.

      • getRevisionCandidates

         final Result<List<String>> getRevisionCandidates(WorkingTree workingTree, Package pkg, Boolean allowMovingRevisions)

        Get a list of distinct revision candidates for the package. The iteration order of the elements in the list represents the priority of the revision candidates. If no revision candidates can be found a DownloadException is thrown.

        The provided workingTree must have been created from the processed VCS information of the package for the function to return correct results.

        allowMovingRevisions toggles whether candidates with symbolic names that point to moving revisions, like Git branches, are accepted or not.

        Revision candidates are created from the processed VCS information of the package and from guessing revisions based on the name and version of the package. This is useful when the metadata of the package does not contain a revision or if the revision points to a non-fetchable commit, but the repository still has a tag for the package version.