use of jetbrains.buildServer.buildTriggers.vcs.git.GitVersion in project teamcity-git by JetBrains.
the class SetUpstreamCommandImpl method call.
public void call() throws VcsException {
GitCommandLine cmd = getCmd();
GitVersion version = cmd.getGitVersion();
if (version.isLessThan(new GitVersion(1, 7, 0))) {
// ability to set upstream was added in 1.7.0
return;
} else if (version.isLessThan(new GitVersion(1, 8, 0))) {
cmd.addParameters("branch", "--set-upstream", myLocalBranch, myUpstreamBranch);
} else {
cmd.addParameters("branch", "--set-upstream-to=" + myUpstreamBranch);
}
CommandUtil.runCommand(cmd.stdErrExpected(false));
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVersion in project teamcity-git by JetBrains.
the class ListConfigCommandImpl method call.
@NotNull
@Override
public String call() throws VcsException {
GitCommandLine cmd = getCmd();
cmd.addParameters("config", "--list");
if (!cmd.getGitVersion().isLessThan(new GitVersion(2, 8, 0))) {
cmd.addParameter("--show-origin");
}
return CommandUtil.runCommand(cmd).getStdout().trim();
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVersion in project teamcity-git by JetBrains.
the class AgentStartupGitDetector method afterAgentConfigurationLoaded.
@Override
public void afterAgentConfigurationLoaded(@NotNull BuildAgent agent) {
if (pathToGitConfigured(agent)) {
LOG.debug("Path to git configured, will not try to detect git");
return;
}
for (String path : getCandidatePaths()) {
try {
final GitVersion version = new AgentGitFacadeImpl(path).version().call();
agent.getConfiguration().addEnvironmentVariable(Constants.TEAMCITY_AGENT_GIT_VERSION, version.toString());
if (version.isSupported()) {
LOG.info("Detect git at " + path);
setPathToGit(agent, path);
break;
} else {
LOG.debug("TeamCity supports Git version " + GitVersion.MIN + " or higher, git at " + path + " has version " + version + " and will not be used");
}
} catch (VcsException e) {
LOG.debug("Cannot run git at " + path, e);
}
}
detectGitLfs(agent);
detectSSH(agent);
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVersion in project teamcity-git by JetBrains.
the class GitDetectorImpl method getGitPathAndVersionInternal.
@NotNull
private GitExec getGitPathAndVersionInternal(@Nullable VcsRoot root, @Nullable BuildAgentConfiguration config, @NotNull AgentRunningBuild build) throws VcsException {
String path = getPathFromRoot(root, config);
if (path != null) {
Loggers.VCS.info("Using vcs root's git: " + path);
} else {
path = build.getSharedBuildParameters().getEnvironmentVariables().get(Constants.TEAMCITY_AGENT_GIT_PATH);
if (path != null) {
Loggers.VCS.info("Using git specified by " + Constants.TEAMCITY_AGENT_GIT_PATH + ": " + path);
} else {
path = defaultGit();
Loggers.VCS.info("Using default git: " + path);
}
}
GitVersion version = getGitVersion(path);
checkVersionIsSupported(path, version);
return new GitExec(path, version, getCygwinBinPath(path));
}
use of jetbrains.buildServer.buildTriggers.vcs.git.GitVersion in project teamcity-git by JetBrains.
the class FetchCommandImpl method call.
public void call() throws VcsException {
final GitCommandLine cmd = getCmd();
final GitVersion gitVersion = cmd.getGitVersion();
cmd.addParameter("fetch");
if (myQuite)
cmd.addParameter("-q");
if (myShowProgress)
cmd.addParameter("--progress");
if (myDepth != null)
cmd.addParameter("--depth=" + myDepth);
if (!myFetchTags)
cmd.addParameter("--no-tags");
if (gitVersion.isGreaterThan(new GitVersion(1, 7, 3))) {
// we process submodules separately
cmd.addParameter("--recurse-submodules=no");
}
cmd.setHasProgress(true);
if (myRefSpecs.size() > 1 && GitVersion.fetchSupportsStdin(gitVersion)) {
cmd.addParameter("--stdin");
cmd.addParameter(getRemote());
runCmd(cmd.stdErrLogLevel("debug"), refSpecsToBytes(cmd));
} else {
cmd.addParameter(getRemote());
myRefSpecs.forEach(refSpec -> cmd.addParameter(refSpec));
runCmd(cmd.stdErrLogLevel("debug"));
}
}
Aggregations