Example usage for org.eclipse.jgit.api Git tagDelete

List of usage examples for org.eclipse.jgit.api Git tagDelete

Introduction

In this page you can find the example usage for org.eclipse.jgit.api Git tagDelete.

Prototype

public DeleteTagCommand tagDelete() 

Source Link

Document

Return a command object used to delete tags

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// w w  w .  ja  v a 2 s  .  c o  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);
    }
}

From source file:org.jclarity.GitReleaseRollback.java

License:Apache License

private void deleteTag() {
    try {/*ww w  . ja  v a2  s  . c  o m*/
        FileRepositoryBuilder builder = new FileRepositoryBuilder();

        FileRepository db = builder.findGitDir(baseDir).readEnvironment().findGitDir().build();

        Git git = new Git(db);

        String scmTag = releaseProperties.getProperty("scm.tag");
        List<String> result = git.tagDelete().setTags(scmTag).call();
        for (String tag : result) {
            git.push().add(":" + tag).call();
        }
    } catch (IOException e) {
        throw new RuntimeException("Failed to read git repo data", e);
    } catch (GitAPIException e) {
        throw new RuntimeException("Failed to remove tag", e);
    }
}