@Test public void guessRestApiInReflog() throws Exception { assume().that(notesMigration.disableChangeReviewDb()).isTrue(); PushOneCommit.Result r = createChange(); Change.Id id = r.getChange().getId(); try (Repository repo = repoManager.openRepository(r.getChange().project())) { File log = new File(repo.getDirectory(), "logs/" + changeMetaRef(id)); if (!log.exists()) { log.getParentFile().mkdirs(); assertThat(log.createNewFile()).isTrue(); } gApi.changes().id(id.get()).topic("foo"); ReflogEntry last = repo.getReflogReader(changeMetaRef(id)).getLastEntry(); assertThat(last).named("last RefLogEntry").isNotNull(); assertThat(last.getComment()).isEqualTo("change.PutTopic"); } }
@Override public boolean accept(ReflogEntry reflogEntry) { ObjectId newId = reflogEntry.getNewId(); ObjectId oldId = reflogEntry.getOldId(); boolean oldIdExpired = !expireCommits.contains(oldId); boolean newIdExpired = !expireCommits.contains(newId); boolean noIdExpired = !oldIdExpired || !newIdExpired; return noIdExpired; }
public void addReflogEntries(List<ReflogEntry> reflogEntries) throws IOException { String refName = getName(); ReflogWriter reflogWriter = getReflogWriter(); for (ReflogEntry nonExpiredEntry : reflogEntries) { ObjectId oldId = nonExpiredEntry.getOldId(); ObjectId newId = nonExpiredEntry.getNewId(); PersonIdent ident = nonExpiredEntry.getWho(); String message = nonExpiredEntry.getComment(); reflogWriter.log(refName, oldId, newId, ident, message); } }
@Override public Void call() throws GitAPIException { checkCallable(); List<Ref> refs = gitRepository.getRefs(Ref.class); List<Predicate<ReflogEntry>> refLogEntryFilterPredicates = new ArrayList<Predicate<ReflogEntry>>(); refLogEntryFilterPredicates.add(expireDatePredicate); refLogEntryFilterPredicates.add(new ReflogEntryFilterPredicateAdapter( reflogEntryFilter)); Predicate<ReflogEntry> refLogEntriesFilter = AllPredicate .allPredicate(refLogEntryFilterPredicates); try { for (Ref ref : refs) { List<ReflogEntry> reflogEntries = ref.getReflogEntries(); Iterator<ReflogEntry> reflogEntryIterator = reflogEntries .iterator(); Iterator<ReflogEntry> filteredReflogEntryIterator = IteratorUtils .filteredIterator(reflogEntryIterator, refLogEntriesFilter); List<ReflogEntry> nonFilteredReflogEntries = IteratorUtils .toList(filteredReflogEntryIterator); ref.clearReflog(); ref.addReflogEntries(nonFilteredReflogEntries); } } catch (IOException e) { throw new GitAPIException("Unable to read reflog entries", e) { private static final long serialVersionUID = 2266798959465371684L; }; } return null; }
@Override public boolean evaluate(ReflogEntry reflogEntry) { PersonIdent who = reflogEntry.getWho(); TimeZone timeZone = who.getTimeZone(); Calendar reflogEntryCalendar = Calendar.getInstance(timeZone); Date when = who.getWhen(); reflogEntryCalendar.setTime(when); boolean isNotExpired = reflogEntryCalendar.after(expireCalendar); return isNotExpired; }
private ReflogEntryInfo newReflogEntryInfo(ReflogEntry e) { return new ReflogEntryInfo( e.getOldId().getName(), e.getNewId().getName(), CommonConverters.toGitPerson(e.getWho()), e.getComment()); }
public static ArrayMemory valueOf(ReflogEntry value) { ArrayMemory memory = new ArrayMemory(); memory.refOfIndex("newId").assign(valueOf(value.getNewId())); memory.refOfIndex("oldId").assign(valueOf(value.getOldId())); memory.refOfIndex("who").assign(value.getWho() == null ? Memory.NULL : valueOf(value.getWho())); memory.refOfIndex("comment").assign(value.getComment()); return memory; }
public static ArrayMemory valueOfReflogEntries(Iterable<ReflogEntry> values) { ArrayMemory memory = new ArrayMemory(); for (ReflogEntry value : values) { memory.add(valueOf(value)); } return memory; }
public List<ReflogEntry> getReflogEntries() throws IOException { Repository repo = gitRepository.getRepository(); ReflogReader reflogReader = repo.getReflogReader(getName()); List<ReflogEntry> reverseEntries = reflogReader.getReverseEntries(); return reverseEntries; }
@Override public boolean accept(ReflogEntry reflogEntry) { return true; }
@Override public boolean evaluate(ReflogEntry reflogEntry) { return reflogEntryFilter.accept(reflogEntry); }
public boolean accept(ReflogEntry reflogEntry);