// ---------------------------------------------------------- public GitRef createTagForObject(String name, ObjectId objectId) { TagCommand tag = new Git(repository).tag(); tag.setName(name); if (objectId == null) { tag.setObjectId(null); } else { RevWalk revWalk = new RevWalk(repository); try { RevCommit commit = revWalk.parseCommit(objectId); tag.setObjectId(commit); } catch (Exception e) { return null; } finally { revWalk.release(); } } try { tag.call(); return refWithName(Constants.R_TAGS + name); } catch (Exception e) { return null; } }
@Override protected void run() throws Exception { Git git = new Git(db); if (tagName != null) { TagCommand command = git.tag().setForceUpdate(force).setMessage(message).setName(tagName); if (object != null) { RevWalk walk = new RevWalk(db); command.setObjectId(walk.parseAny(object)); } command.call(); } else { ListTagCommand command = git.tagList(); List<RevTag> list = command.call(); for (RevTag revTag : list) { out.println(revTag.getTagName()); } } }