/** {@inheritDoc} */ public GitClient subGit(String subdir) { return new CliGitAPIImpl(gitExe, new File(workspace, subdir), listener, environment); }
/** * Remove untracked files and directories, including files listed * in the ignore rules. * * @throws hudson.plugins.git.GitException if underlying git operation fails. * @throws java.lang.InterruptedException if interrupted. */ public void clean() throws GitException, InterruptedException { this.clean(false); }
private void getGitVersion() { if (gitVersion != 0) { return; } String version = ""; try { version = launchCommand("--version").trim(); } catch (Throwable e) { } computeGitVersion(version); }
/* package */ boolean isAtLeastVersion(int major, int minor, int rev, int bugfix) { getGitVersion(); long requestedVersion = computeVersionFromBits(major, minor, rev, bugfix); return gitVersion >= requestedVersion; }
File passphrase = null; EnvVars env = environment; if (!PROMPT_FOR_AUTHENTICATION && isAtLeastVersion(2, 3, 0, 0)) { env = new EnvVars(env); env.put("GIT_TERMINAL_PROMPT", "false"); // Don't prompt for auth from command line git if (isWindows()) { env.put("GCM_INTERACTIVE", "false"); // Don't prompt for auth from git credentials manager for windows key = createSshKeyFile(sshUser); passphrase = createPassphraseFile(sshUser); if (launcher.isUnix()) { ssh = createUnixGitSSH(key, userName); askpass = createUnixSshAskpass(sshUser, passphrase); } else { ssh = createWindowsGitSSH(key, userName); askpass = createWindowsSshAskpass(sshUser, passphrase); usernameFile = createUsernameFile(userPass); passwordFile = createPasswordFile(userPass); if (launcher.isUnix()) { askpass = createUnixStandardAskpass(userPass, usernameFile, passwordFile); } else { askpass = createWindowsStandardAskpass(userPass, usernameFile, passwordFile); return launchCommandIn(args, workDir, env, timeout); } catch (IOException e) { throw new GitException("Failed to setup credentials", e); } finally {
/** {@inheritDoc} */ public void checkout(String ref) throws GitException, InterruptedException { if (Git.USE_CLI) super.checkout(ref); else jgit.checkout(ref); }
/** {@inheritDoc} */ public void commit(String message, PersonIdent author, PersonIdent committer) throws GitException, InterruptedException { if (Git.USE_CLI) super.commit(message, author, committer); else jgit.commit(message, author, committer); }
/** {@inheritDoc} */ public void appendNote(String note, String namespace ) throws GitException, InterruptedException { createNote(note,namespace,"append"); }
/** {@inheritDoc} */ public void branch(String name) throws GitException, InterruptedException { if (Git.USE_CLI) super.branch(name); else jgit.branch(name); } }
/** {@inheritDoc} */ public void add(String filePattern) throws GitException, InterruptedException { if (Git.USE_CLI) super.add(filePattern); else jgit.add(filePattern); }
/* package */ void computeGitVersion(String version) { int gitMajorVersion = 0; int gitMinorVersion = 0; int gitRevVersion = 0; int gitBugfixVersion = 0; try { /* * msysgit adds one more term to the version number. So * instead of Major.Minor.Rev.Bugfix, it displays * something like Major.Minor.Rev.msysgit.BugFix. This * removes the inserted term from the version string * before parsing. * git 2.5.0 for windows adds a similar component with * the string "windows". Remove it as well */ String[] fields = version.split(" ")[2].replace("msysgit.", "").replace("windows.", "").split("\\."); gitMajorVersion = Integer.parseInt(fields[0]); gitMinorVersion = (fields.length > 1) ? Integer.parseInt(fields[1]) : 0; gitRevVersion = (fields.length > 2) ? Integer.parseInt(fields[2]) : 0; gitBugfixVersion = (fields.length > 3) ? Integer.parseInt(fields[3]) : 0; } catch (Throwable e) { /* Oh well */ } gitVersion = computeVersionFromBits(gitMajorVersion, gitMinorVersion, gitRevVersion, gitBugfixVersion); }
/** {@inheritDoc} */ public void checkout(String ref, String branch) throws GitException, InterruptedException { if (Git.USE_CLI) super.checkout(ref, branch); else jgit.checkout(ref, branch); }
/** {@inheritDoc} */ public void commit(String message) throws GitException, InterruptedException { if (Git.USE_CLI) super.commit(message); else jgit.commit(message); }
/** {@inheritDoc} */ public void addNote(String note, String namespace ) throws GitException, InterruptedException { createNote(note,namespace,"add"); }
/** {@inheritDoc} */ public void clean() throws GitException, InterruptedException { if (Git.USE_CLI) super.clean(); else jgit.clean(); }