Example usage for org.eclipse.jgit.api DeleteTagCommand setTags

List of usage examples for org.eclipse.jgit.api DeleteTagCommand setTags

Introduction

In this page you can find the example usage for org.eclipse.jgit.api DeleteTagCommand setTags.

Prototype

public DeleteTagCommand setTags(String... tags) 

Source Link

Document

Set names of the tags to delete

Usage

From source file:com.worldline.easycukes.scm.utils.GitHelper.java

License:Open Source License

/**
 * Delete a tag in the local git repository
 * (git tag -d tagname) and finally pushes new branch on the remote repository (git push)
 *
 * @param directory the directory in which the local git repository is located
 * @param username  the username to be used while pushing
 * @param password  the password matching with the provided username to be used
 *                  for authentication//from ww w.j a va2  s .co m
 * @param message   the commit message to be used    
 */
public static void deleteTag(@NonNull File directory, String tagName, String username, String password,
        String message) {
    try {
        final Git git = Git.open(directory);

        final UsernamePasswordCredentialsProvider userCredential = new UsernamePasswordCredentialsProvider(
                username, password);
        DeleteTagCommand deleteTagCommand = git.tagDelete();
        deleteTagCommand.setTags(tagName);
        deleteTagCommand.call();
        log.info("Tag deleted");

        // and then commit
        final PersonIdent author = new PersonIdent(username, "");
        git.commit().setCommitter(author).setMessage(message).setAuthor(author).call();
        log.info(message);

        git.push().setCredentialsProvider(userCredential).call();
        log.info("Pushed the changes in remote Git repository...");
    } catch (final GitAPIException | IOException e) {
        log.error(e.getMessage(), e);
    }
}