.setName(plugin.getTag()) .setMessage("add " + plugin.getTag()) .call();
Ref tag = git.tag().setName("tag_for_testing").call(); System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(id); tag = git.tag().setObjectId(commit).setName("tag_for_testing").call(); System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); tag = git.tag().setName("tag_for_testing").setAnnotated(true).call(); System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory());
Ref tag = git.tag().setName("tag_for_testing").call(); System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); try (RevWalk walk = new RevWalk(repository)) { RevCommit commit = walk.parseCommit(id); tag = git.tag().setObjectId(commit).setName("tag_for_testing").call(); System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory()); tag = git.tag().setName("tag_for_testing").setAnnotated(true).call(); System.out.println("Created/moved tag " + tag + " to repository at " + repository.getDirectory());
/** * Creates a tag. * * @param git * instance. * @param name * of the tag. * * @return Ref created to tag. */ public Ref createTag(Git git, String name) { try { return git.tag() .setName(name) .call(); } catch (GitAPIException e) { throw new IllegalStateException(e); } }
protected void doCreateTag(Exchange exchange, String operation) throws Exception { if (ObjectHelper.isEmpty(endpoint.getTagName())) { throw new IllegalArgumentException("Tag Name must be specified to execute " + operation); } try { git.tag().setName(endpoint.getTagName()).call(); } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } }
public Ref saveAtHEAD(Git git) throws GitAPIException { String json = message.toJSONString(); ref = git.tag().setName(name()).setAnnotated(true).setMessage(json).call(); return ref; }
private void addTagToCommit(RevCommit commit) throws GitAPIException { pull(); if (!tagPrefix.isEmpty()) { String tagName = tagPrefix + getNextTagId(); git.tag().setObjectId(commit).setName(tagName).call(); } }
/** * Method will tag the current HEAD commit has being the latest published. */ @SneakyThrows public void setPublished() { if (!isUndefined()) { git.tagDelete().setTags("published").call(); git.tag().setName("published").call(); } }
@Override public TagRef tagRepo(String tagName) { try { if (repository == null) { initRepository(); } TagCommand tag = new Git(repository).tag(); LOGGER.debug("Tagging HEAD with name '{}'", tagName); return new GitTagRef(tag.setName(tagName).call()); } catch (Exception e) { throw new ScmException(e); } }
public boolean tag(String tagname, String comment) throws Exception { try{ git.fetch().setTagOpt(TagOpt.FETCH_TAGS).call(); } catch(Exception e) { log.debug("Fetch from origin failed.", e); } List<RevTag> tags = git.tagList().call(); if(tags != null && tags.size() > 0) { for(RevTag tag : tags) { if(tag.getTagName().equals(tagname)) { throw new Exception("Tag already exists."); } } } boolean success = git.tag().setMessage(comment).setName(tagname).call() != null; try{ git.push().setPushTags().call(); } catch(Exception e){ log.debug("Failed to push changes.", e); } return success; }
public void tag(String tagName, String tagRevision, PersonIdent taggerIdent, @Nullable String tagMessage) { try { TagCommand tag = git().tag(); tag.setName(tagName); if (tagMessage != null) tag.setMessage(tagMessage); tag.setTagger(taggerIdent); tag.setObjectId(getRevCommit(tagRevision)); tag.call(); cacheObjectId(GitUtils.tag2ref(tagName), tag.getObjectId()); } catch (GitAPIException e) { throw new RuntimeException(e); } }
@Override public String snapshot(String name, String comment) throws ConfigurationPersistenceException { boolean noComment = (comment ==null || comment.isEmpty()); String message = noComment ? SNAPSHOT_PREFIX + FORMATTER.format(LocalDateTime.now()) : comment; String tagName = (name ==null || name.isEmpty()) ? SNAPSHOT_PREFIX + FORMATTER.format(LocalDateTime.now()) : name; try (Git git = gitRepository.getGit()) { Status status = git.status().call(); List<Ref> tags = git.tagList().call(); String refTagName = R_TAGS + tagName; for(Ref tag : tags) { if(refTagName.equals(tag.getName())) { throw MGMT_OP_LOGGER.snapshotAlreadyExistError(tagName); } } //if comment is not null if(status.hasUncommittedChanges() || !noComment) { git.commit().setMessage(message).setAll(true).setNoVerify(true).call(); } git.tag().setName(tagName).setMessage(message).call(); } catch (GitAPIException ex) { throw MGMT_OP_LOGGER.failedToPersistConfiguration(ex, message, ex.getMessage()); } return message; }
@Override public String snapshot(String name, String comment) throws ConfigurationPersistenceException { boolean noComment = (comment ==null || comment.isEmpty()); String message = noComment ? SNAPSHOT_PREFIX + FORMATTER.format(LocalDateTime.now()) : comment; String tagName = (name ==null || name.isEmpty()) ? SNAPSHOT_PREFIX + FORMATTER.format(LocalDateTime.now()) : name; try (Git git = gitRepository.getGit()) { Status status = git.status().call(); List<Ref> tags = git.tagList().call(); String refTagName = R_TAGS + tagName; for(Ref tag : tags) { if(refTagName.equals(tag.getName())) { throw MGMT_OP_LOGGER.snapshotAlreadyExistError(tagName); } } //if comment is not null if(status.hasUncommittedChanges() || !noComment) { git.commit().setMessage(message).setAll(true).setNoVerify(true).call(); } git.tag().setName(tagName).setMessage(message).call(); } catch (GitAPIException ex) { throw MGMT_OP_LOGGER.failedToPersistConfiguration(ex, message, ex.getMessage()); } return message; }
/** {@inheritDoc} */ @Override public void tag(String name, String message) throws GitException { try (Repository repo = getRepository()) { git(repo).tag().setName(name).setMessage(message).setForceUpdate(true).call(); } catch (GitAPIException e) { throw new GitException(e); } }
@Override public TagRef tagRepo(String tagName, CommitRef ref) { try { if (repository == null) { initRepository(); } AnyObjectId commitRef = repository.resolve(ref.getStringRepresentation()); if (commitRef == null) { LOGGER.debug("Couldnt resolve reference {} in repository", ref.getStringRepresentation()); return null; } RevWalk walk = new RevWalk(repository); RevCommit revCommit = walk.parseCommit(commitRef); TagCommand tag = new Git(repository).tag(); tag.setName(tagName).setObjectId(revCommit); LOGGER.debug("Tagging revision {} with name '{}'", ref.getStringRepresentation(), tagName); return new GitTagRef(tag.call()); } catch (Exception e) { throw new ScmException(e); } }
public Bundle createNewVersion(Bundle bundle) throws NoHeadException, ConcurrentRefUpdateException, InvalidTagNameException, IOException { Preconditions.checkNotNull(bundle, "bundle is null"); Preconditions.checkArgument(bundle.isSnapshot(), "can't release a non-snapshot version"); Bundle current = getBundle(bundle.getName()); Preconditions.checkArgument(bundle.equals(current), "Bundle specifier (%s:%s) is stale. Latest version is %s:%s", bundle.getName(), bundle.getVersion(), bundle.getName(), current.getVersion()); int version = bundle.getVersion(); RevCommit commit = GitUtils.getCommit(git.getRepository(), getBranch(git.getRepository(), bundle.getName())); git.tag().setObjectId(commit) .setName(bundle.getName() + "-" + version) .call(); return new Bundle(bundle.getName(), version, false); }
@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)); } try { command.call(); } catch (RefAlreadyExistsException e) { throw die(MessageFormat.format(CLIText.get().tagAlreadyExists, tagName)); } } else { ListTagCommand command = git.tagList(); List<Ref> list = command.call(); for (Ref ref : list) { outw.println(Repository.shortenRefName(ref.getName())); } } } }
RevCommit commit = prepareCommit(fork, "[PATCH] initialization").call(); fork.tag() .setName("patch-management") .setObjectId(commit) .call();
protected void doTag(String branchToTag, String tagMessage, MergeResult resultToLog, BranchMergingExtension extension) throws GitAPIException, JGitFlowGitAPIException, JGitFlowExtensionException { runExtensionCommands(extension.beforeTag()); git.checkout().setName(branchToTag).call(); String tagName = gfConfig.getPrefixValue(JGitFlowConstants.PREFIXES.VERSIONTAG.configKey()) + getBranchName(); if (!GitHelper.tagExists(git, tagName)) { reporter.infoText( getCommandName(), String.format( "tagging with name: <%s>. merge status (%s)", tagName, resultToLog.getMergeStatus() ) ); git.tag().setName(tagName).setMessage(getScmMessagePrefix() + tagMessage + getScmMessageSuffix()).call(); } runExtensionCommands(extension.afterTag()); }
protected void doTag(String branchToTag, String tagMessage, MergeResult resultToLog, BranchMergingExtension extension) throws GitAPIException, JGitFlowGitAPIException, JGitFlowExtensionException { runExtensionCommands(extension.beforeTag()); git.checkout().setName(branchToTag).call(); String tagName = gfConfig.getPrefixValue(JGitFlowConstants.PREFIXES.VERSIONTAG.configKey()) + getBranchName(); if (!GitHelper.tagExists(git, tagName)) { reporter.infoText( getCommandName(), String.format( "tagging with name: <%s>. merge status (%s)", tagName, resultToLog.getMergeStatus() ) ); git.tag().setName(tagName).setMessage(getScmMessagePrefix() + tagMessage + getScmMessageSuffix()).call(); } runExtensionCommands(extension.afterTag()); }