@Override PersonIdent getAuthor() { return new PersonIdent(description, ""); //$NON-NLS-1$ } }
/** * Create a command to stash changes in the working directory and index * * @param repo * a {@link org.eclipse.jgit.lib.Repository} object. */ public StashCreateCommand(Repository repo) { super(repo); person = new PersonIdent(repo); }
/** * Create new committer {@code PersonIdent} for ketch system * * @param time * timestamp for the committer. * @return identity line for the committer header of a RefTreeGraph. */ public PersonIdent newCommitter(ProposedTimestamp time) { String name = "ketch"; //$NON-NLS-1$ String email = "ketch@system"; //$NON-NLS-1$ return new PersonIdent(name, email, time); }
private static PersonIdent mockAuthor(List<RevCommit> parents) { String name = RecursiveMerger.class.getSimpleName(); int time = 0; for (RevCommit p : parents) time = Math.max(time, p.getCommitTime()); return new PersonIdent( name, name + "@JGit", //$NON-NLS-1$ new Date((time + 1) * 1000L), TimeZone.getTimeZone("GMT+0000")); //$NON-NLS-1$ } }
private static PersonIdent tmpAuthor(List<RevCommit> commits) { // Construct a predictable author using most recent commit time. int t = 0; for (int i = 0; i < commits.size();) { t = Math.max(t, commits.get(i).getCommitTime()); } String name = "Ketch Stage"; //$NON-NLS-1$ String email = "tmp@tmp"; //$NON-NLS-1$ return new PersonIdent(name, email, t * 1000L, 0); }
/** * Sets the committer for this {@code commit}. If no committer is explicitly * specified because this method is never called then the committer will be * deduced from config info in repository, with current time. * * @param name * the name of the committer used for the {@code commit} * @param email * the email of the committer used for the {@code commit} * @return {@code this} */ public CommitCommand setCommitter(String name, String email) { checkCallable(); return setCommitter(new PersonIdent(name, email)); }
/** * Sets the author for this {@code commit}. If no author is explicitly * specified because this method is never called then the author will be set * to the committer or to the original author when amending. * * @param name * the name of the author used for the {@code commit} * @param email * the email of the author used for the {@code commit} * @return {@code this} */ public CommitCommand setAuthor(String name, String email) { checkCallable(); return setAuthor(new PersonIdent(name, email)); }
return new PersonIdent(name, email, when, tz); return null;
private CommitBuilder createBuilder() { CommitBuilder builder = new CommitBuilder(); PersonIdent author = person; if (author == null) author = new PersonIdent(repo); builder.setAuthor(author); builder.setCommitter(author); return builder; }
@Override public ReceivePack create(DaemonClient req, Repository db) throws ServiceNotEnabledException, ServiceNotAuthorizedException { ReceivePack rp = new ReceivePack(db); InetAddress peer = req.getRemoteAddress(); String host = peer.getCanonicalHostName(); if (host == null) host = peer.getHostAddress(); String name = "anonymous"; //$NON-NLS-1$ String email = name + "@" + host; //$NON-NLS-1$ rp.setRefLogIdent(new PersonIdent(name, email)); rp.setTimeout(getTimeout()); return rp; } };
/** * Sets default values for not explicitly specified options. Then validates * that all required data has been provided. * * @param state * the state of the repository we are working on * * @throws InvalidTagNameException * if the tag name is null or invalid * @throws UnsupportedOperationException * if the tag is signed (not supported yet) */ private void processOptions(RepositoryState state) throws InvalidTagNameException { if (tagger == null && annotated) tagger = new PersonIdent(repo); if (name == null || !Repository.isValidRefName(Constants.R_TAGS + name)) throw new InvalidTagNameException( MessageFormat.format(JGitText.get().tagNameInvalid, name == null ? "<null>" : name)); //$NON-NLS-1$ if (signed) throw new UnsupportedOperationException( JGitText.get().signingNotSupportedOnTag); }
private PersonIdent readPersonIdent() { String name = readValueString(); String email = readValueString(); long ms = readVarint64() * 1000; int tz = readInt16(); return new PersonIdent(name, email, ms, tz); }
private void writeLog(ReftableWriter writer, long updateIndex, List<ReceiveCommand> pending) throws IOException { Map<String, ReceiveCommand> cmds = new HashMap<>(); List<String> byName = new ArrayList<>(pending.size()); for (ReceiveCommand cmd : pending) { cmds.put(cmd.getRefName(), cmd); byName.add(cmd.getRefName()); } Collections.sort(byName); PersonIdent ident = getRefLogIdent(); if (ident == null) { ident = new PersonIdent(refdb.getRepository()); } for (String name : byName) { ReceiveCommand cmd = cmds.get(name); if (isRefLogDisabled(cmd)) { continue; } String msg = getRefLogMessage(cmd); if (isRefLogIncludingResult(cmd)) { String strResult = toResultString(cmd); if (strResult != null) { msg = msg.isEmpty() ? strResult : msg + ": " + strResult; //$NON-NLS-1$ } } writer.writeLog(name, updateIndex, ident, cmd.getOldId(), cmd.getNewId(), msg); } }
nextLF(raw, emailE - 1) - 2) + 1; if (tzBegin <= emailE) // No time/zone, still valid return new PersonIdent(name, email, 0, 0); return new PersonIdent(name, email, 0, 0); return new PersonIdent(name, email, when * 1000L, tz);
throws NoMessageException { if (committer == null) committer = new PersonIdent(repo); if (author == null && !amend) author = committer;
/** * Write the given ref update to the ref's log. * * @param update * a {@link org.eclipse.jgit.lib.RefUpdate} * @param msg * reflog message * @param deref * whether to dereference symbolic refs * @return this writer * @throws java.io.IOException */ public ReflogWriter log(RefUpdate update, String msg, boolean deref) throws IOException { ObjectId oldId = update.getOldObjectId(); ObjectId newId = update.getNewObjectId(); Ref ref = update.getRef(); PersonIdent ident = update.getRefLogIdent(); if (ident == null) ident = new PersonIdent(refdb.getRepository()); else ident = new PersonIdent(ident); byte[] rec = encode(oldId, newId, ident, msg); if (deref && ref.isSymbolic()) { log(ref.getName(), rec); log(ref.getLeaf().getName(), rec); } else log(ref.getName(), rec); return this; }
tz = 0; return new PersonIdent(name, email, when * 1000L, tz);
private void writeReflog(List<ReceiveCommand> commands) { PersonIdent ident = getRefLogIdent(); if (ident == null) { ident = new PersonIdent(refdb.getRepository());
static void commitNoteMap(Repository r, String ref, RevWalk walk, NoteMap map, RevCommit notesCommit, ObjectInserter inserter, String msg) throws IOException { // commit the note CommitBuilder builder = new CommitBuilder(); builder.setTreeId(map.writeTree(inserter)); builder.setAuthor(new PersonIdent(r)); builder.setCommitter(builder.getAuthor()); builder.setMessage(msg); if (notesCommit != null) builder.setParentIds(notesCommit); ObjectId commit = inserter.insert(builder); inserter.flush(); RefUpdate refUpdate = r.updateRef(ref); if (notesCommit != null) refUpdate.setExpectedOldObjectId(notesCommit); else refUpdate.setExpectedOldObjectId(ObjectId.zeroId()); refUpdate.setNewObjectId(commit); refUpdate.update(walk); }
private boolean apply(List<Command> todo) throws IOException { if (!tree.apply(todo)) { // apply set rejection information on commands. return false; } Repository repo = refdb.getRepository(); try (ObjectInserter ins = repo.newObjectInserter()) { CommitBuilder b = new CommitBuilder(); b.setTreeId(tree.writeTree(ins)); if (parentTreeId.equals(b.getTreeId())) { for (Command c : todo) { c.setResult(OK); } return true; } if (!parentCommitId.equals(ObjectId.zeroId())) { b.setParentId(parentCommitId); } author = getRefLogIdent(); if (author == null) { author = new PersonIdent(repo); } b.setAuthor(author); b.setCommitter(author); b.setMessage(getRefLogMessage()); newCommitId = ins.insert(b); ins.flush(); } return true; }