/** * Compare an object to this one commit * <p> * An object is equal to this commit object if it is an instance of * {@code JGitCommit} and wraps around the same JGit commit object. * * @param object The object to check for equality * @return {@code true} if the object is equal to this one */ @Override public boolean equals(Object object) { return object instanceof JGitCommit && commit.equals(((JGitCommit) object).commit); }
boolean tryRebase = false; for (RevCommit parentCommit : newCommit.getParents()) if (parentCommit.equals(oldCommit)) tryRebase = true; if (!tryRebase)
@Override public boolean equals(Object object) { return super.equals(object) && targetCommit.equals(((ObjectLink) object).targetCommit); }
private Optional<TaggedVersion> findCurrent(RevCommit head, Stream<TaggedVersion> versions) { return versions .filter(version -> version.getCommit().equals(head)) // if multiple tags on the head commit, we want the highest precedence one .max(Comparator.comparing(TaggedVersion::getVersion)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } TraversalWork other = (TraversalWork) obj; if (currentTagName == null) { if (other.currentTagName != null) { return false; } } else if (!currentTagName.equals(other.currentTagName)) { return false; } if (to == null) { if (other.to != null) { return false; } } else if (!to.equals(other.to)) { return false; } return true; }
public void run() { CommitSelectDialog dlg = new CommitSelectDialog( HandlerUtil.getActiveShell(event), commits); if (dlg.open() == Window.OK) for (PreviousCommit pc: previousList) if (pc.commit.equals(dlg.getSelectedCommit())){ previous.set(pc); break; } } });
boolean otherParentsUnchanged = true; for (int i = 1; i < commitToPick.getParentCount(); i++) otherParentsUnchanged &= newParents.get(i).equals( commitToPick.getParent(i));
/** * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (obj == this) return true; else if (obj instanceof CommitEditorInput) { RepositoryCommit inputCommit = ((CommitEditorInput) obj).commit; return commit.getRevCommit().equals(inputCommit.getRevCommit()) && commit.getRepository().equals( inputCommit.getRepository()); } else return false; }
public static boolean currentCommitsAreEqual(Path dir1, Path dir2) { try { RevCommit commit1 = new Git( new FileRepositoryBuilder().setWorkTree( dir1.toFile().getAbsoluteFile() ).build() ).log().call().iterator().next(); RevCommit commit2 = new Git( new FileRepositoryBuilder().setWorkTree( dir2.toFile().getAbsoluteFile() ).build() ).log().call().iterator().next(); return commit1.equals(commit2); } catch (IOException e) { throw new RuntimeException(e); } catch (NoHeadException e) { return false; } catch (GitAPIException e) { throw new RuntimeException(e); } }
private Optional<Version> findParallel(RevWalk walk, RevCommit head, TaggedVersion candidate, Set<RevCommit> tagged) { try { walk.reset(); walk.setRevFilter(RevFilter.MERGE_BASE); walk.markStart(head); walk.markStart(candidate.getCommit()); RevCommit mergeBase = walk.next(); walk.reset(); walk.setRevFilter(RevFilter.ALL); boolean taggedSinceMergeBase = RevWalkUtils.find(walk, head, mergeBase).stream() .filter(tagged::contains) .findAny() .isPresent(); if (mergeBase != null && !taggedSinceMergeBase && !mergeBase.equals(head) && !mergeBase.equals(candidate.getCommit())) { return Optional.of(candidate.getVersion().getNormal()); } else { return Optional.empty(); } } catch (IOException e) { throw new UncheckedIOException(e); } }
protected boolean isClean(Git git) throws GitAPIException, IOException { if (git.getRepository().getBranch().equals(BASE_BRANCH)) { Optional<Ref> baseBranch = getOriginHead(git); if (baseBranch.isPresent()) { RevWalk walk = new RevWalk(git.getRepository()); RevCommit baseCommit = walk.parseCommit(getBaseObjectId(git)); RevCommit headCommit = walk.parseCommit(getHead(git).getObjectId()); log.info(String.format("origin/master sha: [%s], head: [%s]", baseCommit.getName(), headCommit.getName())); return baseCommit.equals(headCommit) && git.status().call().isClean(); } else { // there is no origin Status status = git.status().call(); boolean isClean = status.isClean(); if (!isClean) { log.info("Untracked Folders: " + Arrays.toString(status.getUntrackedFolders().toArray())); log.info("Untracked Files: " + Arrays.toString(status.getUntracked().toArray())); log.info("Changed Files: " + Arrays.toString(status.getChanged().toArray())); log.info("Added Files: " + Arrays.toString(status.getAdded().toArray())); log.info("Removed Files: " + Arrays.toString(status.getRemoved().toArray())); log.info("Uncommitted Files: " + Arrays.toString(status.getUncommittedChanges().toArray())); } return isClean; } } return false; }
private List<Ref> loadTags() { RepositoryCommit repoCommit = getCommit(); RevCommit commit = repoCommit.getRevCommit(); Repository repository = repoCommit.getRepository(); List<Ref> tags = new ArrayList<Ref>(); for (Ref tag : getTags()) { tag = repository.peel(tag); ObjectId id = tag.getPeeledObjectId(); if (id == null) id = tag.getObjectId(); if (!commit.equals(id)) continue; tags.add(tag); } return tags; }
public Bundle getBundle(String name) throws IOException { Ref branch = getBranch(git.getRepository(), name); if (branch != null) { int version = 0; Ref latestTag = getLatestTag(name); if (latestTag != null) { version = extractVersion(latestTag.getName()); } RevCommit headCommit = GitUtils.getCommit(git.getRepository(), branch); boolean snapshot = (latestTag == null || !GitUtils.getCommit(git.getRepository(), latestTag).equals(headCommit)); if (snapshot) { ++version; } return new Bundle(name, version, snapshot); } return null; }
boolean tryRebase = false; for (RevCommit parentCommit : newCommit.getParents()) if (parentCommit.equals(oldCommit)) tryRebase = true; if (!tryRebase)
boolean tryRebase = false; for (RevCommit parentCommit : newCommit.getParents()) if (parentCommit.equals(oldCommit)) tryRebase = true; if (!tryRebase)