Class SubmoduleAddCommand

All Implemented Interfaces:
Callable<Repository>

public class SubmoduleAddCommand extends TransportCommand<SubmoduleAddCommand,Repository>
A class used to execute a submodule add command. This will clone the configured submodule, register the submodule in the .gitmodules file and the repository config file, and also add the submodule and .gitmodules file to the index.
See Also:
  • Field Details

  • Constructor Details

    • SubmoduleAddCommand

      public SubmoduleAddCommand(Repository repo)
      Constructor for SubmoduleAddCommand.
      Parameters:
      repo - a Repository object.
  • Method Details

    • setName

      public SubmoduleAddCommand setName(String name)
      Set the submodule name
      Parameters:
      name -
      Returns:
      this command
      Since:
      5.1
    • setPath

      public SubmoduleAddCommand setPath(String path)
      Set repository-relative path of submodule
      Parameters:
      path - (with / as separator)
      Returns:
      this command
    • setURI

      public SubmoduleAddCommand setURI(String uri)
      Set URI to clone submodule from
      Parameters:
      uri - a String object.
      Returns:
      this command
    • setProgressMonitor

      public SubmoduleAddCommand setProgressMonitor(ProgressMonitor monitor)
      The progress monitor associated with the clone operation. By default, this is set to NullProgressMonitor
      Parameters:
      monitor - a ProgressMonitor object.
      Returns:
      this command
      See Also:
    • submoduleExists

      protected boolean submoduleExists() throws IOException
      Is the configured already a submodule in the index?
      Returns:
      true if submodule exists in index, false otherwise
      Throws:
      IOException
    • call

      public Repository call() throws GitAPIException

      Execute the command

      Executes the SubmoduleAddCommand The Repository instance returned by this command needs to be closed by the caller to free resources held by the Repository instance. It is recommended to call this method as soon as you don't need a reference to this Repository instance anymore.

      Specified by:
      call in interface Callable<Repository>
      Specified by:
      call in class GitCommand<Repository>
      Throws:
      GitAPIException