public interface

GitScmConfig

com.atlassian.bitbucket.scm.git.GitScmConfig

Class Overview

Provides access to the configuration for the git SCM.

Summary

Public Methods
@Deprecated long getBackendExecutionTimeLimit()
This method is deprecated. in 5.1 for removal without replacement in 6.0.
@Deprecated long getBackendIdleTimeout()
This method is deprecated. in 5.1 for removal without replacement in 6.0.
@Nonnull String getBinary()
Retrieves the path to the git binary.
@Nonnull List<String> getCoreBinary(String command)
Retrieves a path suitable for executing a git-core binary, in a mutable list.
@Deprecated long getGcIntervalInSeconds()
This method is deprecated. in 5.1 for removal without replacement in 6.0.
@Deprecated int getGcThresholdLoose()
This method is deprecated. in 5.1 for removal without replacement in 6.0.
@Deprecated int getGcThresholdPack()
This method is deprecated. in 5.1 for removal without replacement in 6.0.
@Deprecated long getGcTimeoutInSeconds()
This method is deprecated. in 5.1 for removal without replacement in 6.0.
@Nonnull Optional<Version> getInstalledVersion()
Retrieves the version of the installed git binary, if an acceptable version was found.
@Nonnull File getObjectsDir(Repository repository)
Retrieves a File denoting the absolute path to the objects directory within the specified Repository's directory.
boolean getProperty(String propertyName, boolean defaultValue)
Retrieves the named configuration property interpreted as a boolean value.
int getProperty(String propertyName, int defaultValue)
Retrieves the named configuration property interpreted as a int value.
@Nonnull String getProperty(String propertyName, String defaultValue)
Retrieves the named configuration property, defaulted if it has not been configured.
@Nullable String getProperty(String propertyName)
Retrieves the named configuration property.
long getProperty(String propertyName, long defaultValue)
Retrieves the named configuration property interpreted as a long value.
@Nonnull String getRelativePath(Repository repository, Repository relativeTo)
Retrieves a relative path from the root of one repository to another.
@Nonnull File getRepositoriesDir()
Retrieves a File denoting the absolute path to the directory where all repositories are stored on disk.
@Nonnull File getRepositoryDir(Repository repository)
Retrieves a File denoting the absolute path to the specified repository on disk.
@Nonnull File getTempDir()
Retrieves a File denoting the absolute path to a location on disk where temporary files created by the git plugin are stored.
@Nonnull Version getVersion()
Retrieves the version of the current git binary, if an acceptable version is installed.

Public Methods

@Deprecated public long getBackendExecutionTimeLimit ()

This method is deprecated.
in 5.1 for removal without replacement in 6.0.

Determines the time (in seconds) that a git hosting process (e.g. git-http-backend for HTTP or git-upload-pack/git-receive-pack for SSH) is allowed to live, even if output is still being generated.

Returns
  • the execution time limit for a hosting process

@Deprecated public long getBackendIdleTimeout ()

This method is deprecated.
in 5.1 for removal without replacement in 6.0.

Determines the time (in seconds) that a git hosting process (e.g. git-http-backend for HTTP or git-upload-pack/git-receive-pack for SSH) is allowed to live without generating any output.

Returns
  • the idle timeout for a hosting process

@Nonnull public String getBinary ()

Retrieves the path to the git binary.

Returns
  • the path to git
Throws
GitNotFoundException if the git binary could not be found
GitUnsupportedVersionException if the git binary was found but does not meet the minimum version required

@Nonnull public List<String> getCoreBinary (String command)

Retrieves a path suitable for executing a git-core binary, in a mutable list. Callers are free to append additional command arguments to the returned list in constructing their commands.

Earlier versions of git used binaries which were stored in a libexec/git-core directory to do much of their work. For example, executing git add would actually fork out git-add. Since then, the functionality for most of these binaries has been compiled directly into git, with the files in the libexec/git-core directory being replaced by symbolic links back to git.

However, some core binaries still exist, and are still external. One example is git-http-backend, which is used to support push and pull operations over HTTP. When using such commands, there are scalability and performance benefits associated with skipping the lead git http-backend process and dropping directly to the git-http-backend binary that will actually be doing most of the work.

This method provides an abstraction for retrieving a core binary in libexec/git-core. Implementations of this method are required to be aware of whether a core binary actually exists, and to not return an invalid path when a request is made for a core binary that doesn't exist. However, implementations are free to simply return the standard git binary at will. The only requirement is that they not return invalid paths.

Parameters
command the core binary to retrieve
Returns
  • a command list suitable for use in creating an external process
Throws
GitNotFoundException if the git binary could not be found
NullPointerException if the provided command is null
GitUnsupportedVersionException if the git binary was found but does not meet the minimum version required

@Deprecated public long getGcIntervalInSeconds ()

This method is deprecated.
in 5.1 for removal without replacement in 6.0.

The minimum time in seconds between two garbage collection runs in a repository

Returns
  • the minimum time between garbage collection runs

@Deprecated public int getGcThresholdLoose ()

This method is deprecated.
in 5.1 for removal without replacement in 6.0.

Determines the maximum amount of loose files that is allowed to exist in a repository, before triggering a garbage collection run on the next push.

Returns
  • the number of loose files that triggers garbage collection

@Deprecated public int getGcThresholdPack ()

This method is deprecated.
in 5.1 for removal without replacement in 6.0.

Determines the maximum amount of pack files that is allowed to exist in a repository, before triggering a garbage collection run on the next push.

Returns
  • the number of pack files that triggers garbage collection

@Deprecated public long getGcTimeoutInSeconds ()

This method is deprecated.
in 5.1 for removal without replacement in 6.0.

Returns
  • the maximum time in seconds garbage collection processes are allowed to run

@Nonnull public Optional<Version> getInstalledVersion ()

Retrieves the version of the installed git binary, if an acceptable version was found.

If git was not found, or is not an acceptable version, unlike #getVersion(), empty() is returned instead of an exception being thrown.

Returns
  • the installed git version, or empty() if git was not found or was not an acceptable version

@Nonnull public File getObjectsDir (Repository repository)

Retrieves a File denoting the absolute path to the objects directory within the specified Repository's directory.

Parameters
repository the repository to retrieve an objects path for
Returns
  • the absolute path to the specified repository's objects directory
Throws
NullPointerException if the provided repository is null

public boolean getProperty (String propertyName, boolean defaultValue)

Retrieves the named configuration property interpreted as a boolean value.

Parameters
propertyName the property to retrieve
defaultValue the default value to be returned if the property is not configured
Returns
  • the configured property value, or the default value if the property is not configured
Throws
NullPointerException if the provided propertyName is null

public int getProperty (String propertyName, int defaultValue)

Retrieves the named configuration property interpreted as a int value.

Parameters
propertyName the property to retrieve
defaultValue the default value to be returned if the property is not configured
Returns
  • the configured property value, or the default value if the property is not configured
Throws
NullPointerException if the provided propertyName is null

@Nonnull public String getProperty (String propertyName, String defaultValue)

Retrieves the named configuration property, defaulted if it has not been configured.

Parameters
propertyName the property to retrieve
defaultValue the default value to be returned if the property is not configured
Returns
  • the configurd property value, or the default value if the property is not configured
Throws
NullPointerException if the provided propertyName or defaultValue is null

@Nullable public String getProperty (String propertyName)

Retrieves the named configuration property.

Parameters
propertyName the property to retrieve
Returns
  • the configured property value, or null if one is not configured
Throws
NullPointerException if the provided propertyName is null

public long getProperty (String propertyName, long defaultValue)

Retrieves the named configuration property interpreted as a long value.

Parameters
propertyName the property to retrieve
defaultValue the default value to be returned if the property is not configured
Returns
  • the configured property value, or the default value if the property is not configured
Throws
NullPointerException if the provided propertyName is null

@Nonnull public String getRelativePath (Repository repository, Repository relativeTo)

Retrieves a relative path from the root of one repository to another.

Parameters
repository the destination repository
relativeTo the starting repository
Returns
  • a relative path that, if appended to the relativeTo repository's path, would point to the specified repository

@Nonnull public File getRepositoriesDir ()

Retrieves a File denoting the absolute path to the directory where all repositories are stored on disk. While every repository will be in a subdirectory of the returned directory, callers should not make any assumptions about how repository subdirectories will be laid out. That layout is an implementation detail and, as such, is subject to change over time.

The returned File is guaranteed to exist, and to be a directory.

Returns
  • the absolute path to the top-level repositories directory

@Nonnull public File getRepositoryDir (Repository repository)

Retrieves a File denoting the absolute path to the specified repository on disk.

The returned File is not guaranteed to exist, but it is guaranteed to be a directory if it does exist.

Parameters
repository the repository to retrieve a path for
Returns
  • the absolute path to the specified repository
Throws
NullPointerException if the provided repository is null

@Nonnull public File getTempDir ()

Retrieves a File denoting the absolute path to a location on disk where temporary files created by the git plugin are stored.

Returns
  • the absolute path to the temporary file store

@Nonnull public Version getVersion ()

Retrieves the version of the current git binary, if an acceptable version is installed. If git was not found, or if it is not an acceptable version, an exception is thrown.

This method should only be used after system startup is complete. For example, it should not be called in constructors, as doing so may result in an exception that causes the plugin to fail to start. To do one-time version checks in constructors, use getInstalledVersion() instead.

Returns
  • the git version in use, if an acceptable version is installed; otherwise, an exception is thrown
Throws
GitNotFoundException if the git binary could not be found
GitUnsupportedVersionException if the git binary was found but does not meet the MINIMUM_VERSION minimum version required