/** {@inheritDoc} */ @Override public ObjectId getResultTreeId() { return (resultTree == null) ? null : resultTree.toObjectId(); }
/** {@inheritDoc} */ @Override public ObjectId getResultTreeId() { return (resultTree == null) ? null : resultTree.toObjectId(); }
@Override public ObjectId getResultTreeId() { return (resultTree == null) ? null : resultTree.toObjectId(); }
/** * Gets git base. * * @param absoluteFile the absolute file * @param def the def * @return the git base */ protected static String getGitBase(File absoluteFile, String def) { try { Repository repository = new RepositoryBuilder().setWorkTree(absoluteFile).build(); StoredConfig config = repository.getConfig(); String head = repository.resolve("HEAD").toObjectId().getName(); String remoteUrl = config.getString("remote", "origin", "url"); Pattern githubPattern = Pattern.compile("git@github.com:([^/]+)/([^/]+).git"); Matcher matcher = githubPattern.matcher(remoteUrl); if (matcher.matches()) { return "https://github.com/" + matcher.group(1) + "/" + matcher.group(2) + "/tree/" + head + "/src/"; } } catch (Throwable e) { logger.debug("Error querying local git config for " + absoluteFile, e); } return def; }
/** * Gets git base. * * @param absoluteFile the absolute file * @param def the def * @return the git base */ protected static String getGitBase(File absoluteFile, String def) { try { Repository repository = new RepositoryBuilder().setWorkTree(absoluteFile).build(); StoredConfig config = repository.getConfig(); String head = repository.resolve("HEAD").toObjectId().getName(); String remoteUrl = config.getString("remote", "origin", "url"); Pattern githubPattern = Pattern.compile("git@github.com:([^/]+)/([^/]+).git"); Matcher matcher = githubPattern.matcher(remoteUrl); if (matcher.matches()) { return "https://github.com/" + matcher.group(1) + "/" + matcher.group(2) + "/tree/" + head + "/src/"; } } catch (Throwable e) { logger.debug("Error querying local git config for " + absoluteFile, e); } return def; }
private void performPullIfNecessary(Git git, PullRequest pr) throws GitAPIException, IOException { compareAndLogLocalAndRemoteBranches(git, pr); List<RevCommit> commitsInRemoteBranchOnlyBeforeWeDoAnything = getCommitsInBranchOnly(git, pr, false); List<RevCommit> commitsInLocalBranchOnlyBeforeWeDoAnything = getCommitsInBranchOnly(git, pr, true); if (commitsInRemoteBranchOnlyBeforeWeDoAnything.size() > commitsInLocalBranchOnlyBeforeWeDoAnything.size()) { log.info("more commits in remote branch than in local branch -> need for 'git pull'.."); PullResult pullResult = gitWrapper.pull(git); if (pullResult.isSuccessful()) { log.info("pull result OK - merged commits : "); Arrays.stream(pullResult.getMergeResult().getMergedCommits()).forEach(commit -> log.info("\t - {}", commit.toObjectId())); } else { String errorMessage = "unexpected things happened during simple pull operation"; log.warn(errorMessage); throw new CiDroidGitApiException(errorMessage); } compareAndLogLocalAndRemoteBranches(git, pr); } }
public String describe() throws InvalidPatternException, GitAPIException, IOException { String version = git.describe().setMatch( VERSION_GLOB ).call(); if ( version == null ) { Ref mostRecentTag = findMostRecentTag(); if ( mostRecentTag != null ) { String vtag = StringUtils.removeStart( mostRecentTag.getName(), TAG_PREFIX ); ObjectId head = getRepo().resolve( "HEAD" ); long commitCount = countCommits( mostRecentTag.getPeeledObjectId(), head.toObjectId() ); version = String.join( "-", vtag, String.valueOf( commitCount ), 'g' + head.name().substring( 0, 7 ), "SNAPSHOT" ); } } return version; }
@Nullable public String describe() throws InvalidPatternException, GitAPIException, IOException { String version = git.describe().setMatch( VERSION_GLOB ).call(); if ( version == null ) { Ref mostRecentTag = findMostRecentTag(); if ( mostRecentTag != null ) { String vtag = StringUtils.removeStart( mostRecentTag.getName(), TAG_PREFIX ); ObjectId head = getRepo().resolve( "HEAD" ); long commitCount = countCommits( mostRecentTag.getPeeledObjectId(), head.toObjectId() ); version = String.join( "-", vtag, String.valueOf( commitCount ), 'g' + head.name().substring( 0, 7 ), "SNAPSHOT" ); } } return version; }
String describe() throws InvalidPatternException, GitAPIException, IOException { String version = git.describe().setMatch( VERSION_GLOB ).call(); if ( version == null ) { Ref mostRecentTag = findMostRecentTag(); if ( mostRecentTag != null ) { String vtag = StringUtils.removeStart( mostRecentTag.getName(), TAG_PREFIX ); ObjectId head = getRepo().resolve( "HEAD" ); long commitCount = countCommits( mostRecentTag.getPeeledObjectId(), head.toObjectId() ); version = String.join( "-", vtag, String.valueOf( commitCount ), 'g' + head.name().substring( 0, 7 ), "SNAPSHOT" ); } } return version; }