@Override public RevListCommand nowalk(boolean nowalk) { // --no-walk wasn't introduced until v1.5.3 if (isAtLeastVersion(1, 5, 3, 0)) { this.nowalk = nowalk; } return this; }
@Override public Map<String, String> getRemoteSymbolicReferences(String url, String pattern) throws GitException, InterruptedException { Map<String, String> references = new HashMap<>(); if (isAtLeastVersion(2, 8, 0, 0)) { // --symref is only understood by ls-remote starting from git 2.8.0 // https://github.com/git/git/blob/afd6726309/Documentation/RelNotes/2.8.0.txt#L72-L73 ArgumentListBuilder args = new ArgumentListBuilder("ls-remote"); args.add("--symref"); args.add(url); if (pattern != null) { args.add(pattern); } StandardCredentials cred = credentials.get(url); if (cred == null) cred = defaultCredentials; String result = launchCommandWithCredentials(args, null, cred, url); String[] lines = result.split("\n"); Pattern symRefPattern = Pattern.compile("^ref:\\s+([^ ]+)\\s+([^ ]+)$"); for (String line : lines) { Matcher matcher = symRefPattern.matcher(line); if (matcher.matches()) { references.put(matcher.group(2), matcher.group(1)); } } } return references; }
/** {@inheritDoc} */ public void fetch(String remoteName, RefSpec... refspec) throws GitException, InterruptedException { listener.getLogger().println( "Fetching upstream changes" + (remoteName != null ? " from " + remoteName : "")); ArgumentListBuilder args = new ArgumentListBuilder(); args.add("fetch", "-t"); if (USE_FORCE_FETCH && isAtLeastVersion(2, 20, 0, 0)) { /* CLI git 2.20.0 fixed a long-standing bug that now requires --force to update existing tags */ args.add("--force"); } if (remoteName == null) remoteName = getDefaultRemote(); String url = getRemoteUrl(remoteName); if (url == null) throw new GitException("remote." + remoteName + ".url not defined"); args.add(url); if (refspec != null && refspec.length > 0) for (RefSpec rs: refspec) if (rs != null) args.add(rs.toString()); StandardCredentials cred = credentials.get(url); if (cred == null) cred = defaultCredentials; launchCommandWithCredentials(args, workspace, cred, url); }
args.add("--init", "--recursive"); if (remoteTracking && isAtLeastVersion(1,8,2,0)) { args.add("--remote"); depth = 1; if (isAtLeastVersion(1, 8, 4, 0)) { args.add("--depth=" + depth); } else {
args.add("fetch"); args.add(tags ? "--tags" : "--no-tags"); if (USE_FORCE_FETCH && isAtLeastVersion(2, 20, 0, 0)) { if (isAtLeastVersion(1,7,1,0)) args.add("--progress");
@Override public void execute() throws GitException, InterruptedException { ArgumentListBuilder args = new ArgumentListBuilder(); args.add("push", remote.toPrivateASCIIString()); if (refspec != null) { args.add(refspec); } if (force) { args.add("-f"); } if (tags) { args.add("--tags"); } if (!isAtLeastVersion(1,9,0,0) && isShallowRepository()) { throw new GitException("Can't push from shallow repository using git client older than 1.9.0"); } StandardCredentials cred = credentials.get(remote.toPrivateString()); if (cred == null) cred = defaultCredentials; launchCommandWithCredentials(args, workspace, cred, remote, timeout); // Ignore output for now as there's many different formats // That are possible. } };
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