Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » [SOLVED][JGit] Use TagCommand to add a tag on HEAD
icon5.gif  [SOLVED][JGit] Use TagCommand to add a tag on HEAD [message #1066814] Thu, 04 July 2013 13:42 Go to next message
Michaël Adjedj is currently offline Michaël Adjedj
Messages: 8
Registered: June 2013
Location: France, Montpellier
Junior Member
Hello everyone,
I'm still on my update manager project.
but now I continue with "TagCommand".

I want to put a tag (with a message or not) on the HEAD but right now I don't know what I have to do.

Here's the code :

 
public class TagService {
 
    public static void tag(String recup) throws IOException, GitAPIException {
        System.out.println("Ajout d'un tag sur la dernière version");
        String depotLocalString = recup;
        Repository depotLocal;
        depotLocal = new FileRepository(depotLocalString);
        Git git = new Git(depotLocal);
 
        RevObject id = null;
        
        git.tag().setMessage("testTag-1");
 
        System.out.println(git.tag().getMessage());
    }
}


If anyone can help me thank you.


Sorry for my English I'm French.

[Updated on: Mon, 08 July 2013 08:30]

Report message to a moderator

Re: [JGit] Use TagCommand to add a tag on HEAD [message #1067109 is a reply to message #1066814] Fri, 05 July 2013 22:01 Go to previous messageGo to next message
Christian Halstrick is currently offline Christian Halstrick
Messages: 106
Registered: July 2009
Senior Member
You forgot to call the call() Method. Find a Lot of Exampels in https://github.com/eclipse/jgit/blob/master/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/TagCommandTest.java


Ciao
Chris
Re: [JGit] Use TagCommand to add a tag on HEAD [message #1067290 is a reply to message #1067109] Mon, 08 July 2013 08:27 Go to previous message
Michaël Adjedj is currently offline Michaël Adjedj
Messages: 8
Registered: June 2013
Location: France, Montpellier
Junior Member
Hello Christian and thanks for your answer.
I finally find three problems :
- forgot the call();
- the Syso is not a good technique to watch the result
- and my bare was a little bit broken.

Now, it looks like this :

public static void tag(Projet p) throws IOException, GitAPIException {
        System.out.println("Ajout d'un tag sur la dernière version");
        String depotLocalString = p.getRepoLocal()+".git";
        Repository depotLocal;
        depotLocal = new FileRepository(depotLocalString);
        Git git = new Git(depotLocal);
        
        RevWalk walk = new RevWalk(depotLocal);
        AnyObjectId aoi = git.getRepository().getRef(Constants.HEAD).getObjectId();
        RevObject revObject = walk.parseAny(aoi);
        System.out.println("revObject ==> "+revObject.toString());
        git.tag().setObjectId(revObject).setMessage("Tag avec PushTag").setName("testTag-3").call();
        git.push().setPushTags().call();
        
    }


thank you again.


Sorry for my English I'm French.
Previous Topic:Simple Git client using JGit has trouble with fetch/pull
Next Topic:Multi-threaded/Multiprocess Jgit use
Goto Forum:
  


Current Time: Sat Oct 25 19:09:12 GMT 2014

Powered by FUDForum. Page generated in 0.01875 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software