Java Code Examples for org.eclipse.jgit.api.TagCommand#setName()

The following examples show how to use org.eclipse.jgit.api.TagCommand#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateTagCommand.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    try {
        RevObject obj = Utils.findObject(repository, taggedObject);
        TagCommand cmd = new Git(repository).tag();
        cmd.setName(tagName);
        cmd.setForceUpdate(forceUpdate);
        cmd.setObjectId(obj);
        cmd.setAnnotated(message != null && !message.isEmpty() || signed);
        if (cmd.isAnnotated()) {
            cmd.setMessage(message);
            cmd.setSigned(signed);
        }
        cmd.call();
        ListTagCommand tagCmd = new ListTagCommand(repository, getClassFactory(), false, new DelegatingGitProgressMonitor(monitor));
        tagCmd.run();
        Map<String, GitTag> tags = tagCmd.getTags();
        tag = tags.get(tagName);
    } catch (JGitInternalException | GitAPIException ex) {
        throw new GitException(ex);
    }
}
 
Example 2
Source File: Project.java    From onedev with MIT License 5 votes vote down vote up
public void createTag(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, true));
	tag.call();
	
	String refName = GitUtils.tag2ref(tagName);
	cacheObjectId(refName, tag.getObjectId());
	
   	ObjectId commitId = tag.getObjectId().copy();
   	OneDev.getInstance(TransactionManager.class).runAfterCommit(new Runnable() {

		@Override
		public void run() {
	    	OneDev.getInstance(SessionManager.class).runAsync(new Runnable() {

				@Override
				public void run() {
					Project project = OneDev.getInstance(ProjectManager.class).load(getId());
					OneDev.getInstance(ListenerRegistry.class).post(
							new RefUpdated(project, refName, ObjectId.zeroId(), commitId));
				}
	    		
	    	});
		}
   		
   	});			
} catch (GitAPIException e) {
	throw new RuntimeException(e);
}
  }