List of usage examples for org.eclipse.jgit.lib RefRename getRefLogMessage
public String getRefLogMessage()
From source file:com.gitblit.tickets.BranchTicketService.java
License:Apache License
/** * Returns a RefModel for the refs/meta/gitblit/tickets branch in the repository. * If the branch can not be found, null is returned. * * @return a refmodel for the gitblit tickets branch or null *//*from w w w .j a va 2 s . c o m*/ private RefModel getTicketsBranch(Repository db) { List<RefModel> refs = JGitUtils.getRefs(db, "refs/"); Ref oldRef = null; for (RefModel ref : refs) { if (ref.reference.getName().equals(BRANCH)) { return ref; } else if (ref.reference.getName().equals("refs/gitblit/tickets")) { oldRef = ref.reference; } } if (oldRef != null) { // rename old ref to refs/meta/gitblit/tickets RefRename cmd; try { cmd = db.renameRef(oldRef.getName(), BRANCH); cmd.setRefLogIdent(new PersonIdent("Gitblit", "gitblit@localhost")); cmd.setRefLogMessage("renamed " + oldRef.getName() + " => " + BRANCH); Result res = cmd.rename(); switch (res) { case RENAMED: log.info(db.getDirectory() + " " + cmd.getRefLogMessage()); return getTicketsBranch(db); default: log.error("failed to rename " + oldRef.getName() + " => " + BRANCH + " (" + res.name() + ")"); } } catch (IOException e) { log.error("failed to rename tickets branch", e); } } return null; }
From source file:com.gitblit.utils.RefLogUtils.java
License:Apache License
/** * Returns a RefModel for the reflog branch in the repository. If the * branch can not be found, null is returned. * * @param repository// w w w . j a va 2s .co m * @return a refmodel for the reflog branch or null */ public static RefModel getRefLogBranch(Repository repository) { List<RefModel> refs = JGitUtils.getRefs(repository, "refs/"); Ref oldRef = null; for (RefModel ref : refs) { if (ref.reference.getName().equals(GB_REFLOG)) { return ref; } else if (ref.reference.getName().equals("refs/gitblit/reflog")) { oldRef = ref.reference; } else if (ref.reference.getName().equals("refs/gitblit/pushes")) { oldRef = ref.reference; } } if (oldRef != null) { // rename old ref to refs/meta/gitblit/reflog RefRename cmd; try { cmd = repository.renameRef(oldRef.getName(), GB_REFLOG); cmd.setRefLogIdent(new PersonIdent("Gitblit", "gitblit@localhost")); cmd.setRefLogMessage("renamed " + oldRef.getName() + " => " + GB_REFLOG); Result res = cmd.rename(); switch (res) { case RENAMED: LOGGER.info(repository.getDirectory() + " " + cmd.getRefLogMessage()); return getRefLogBranch(repository); default: LOGGER.error( "failed to rename " + oldRef.getName() + " => " + GB_REFLOG + " (" + res.name() + ")"); } } catch (IOException e) { LOGGER.error("failed to rename reflog", e); } } return null; }