[SOLVED][JGit] Use TagCommand to add a tag on HEAD [message #1066814] |
Thu, 04 July 2013 13:42 |
|
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 #1067290 is a reply to message #1067109] |
Mon, 08 July 2013 08:27 |
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.02777 seconds