Example usage for org.eclipse.jgit.lib RefUpdate delete

List of usage examples for org.eclipse.jgit.lib RefUpdate delete

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib RefUpdate delete.

Prototype

public Result delete() throws IOException 

Source Link

Document

Delete the ref.

Usage

From source file:org.kuali.student.git.importer.FixImportRepo.java

License:Educational Community License

private static void deleteRef(Repository repo, String branchName, String revision) throws IOException {

    RefUpdate u = repo.updateRef(branchName, true);

    u.setForceUpdate(true);//from   w  ww .  j a  v a  2s  .  c  om

    String resultMessage = "deleting branch " + branchName + " at revision " + revision;

    u.setRefLogMessage(resultMessage, true);

    Result result = u.delete();

    log.info(resultMessage + " result = " + result);

}

From source file:org.kuali.student.git.model.ref.utils.GitRefUtils.java

License:Educational Community License

public static Result deleteRef(Repository repo, Ref ref, boolean force) throws IOException {

    RefUpdate refUpdate = repo.getRefDatabase().newUpdate(ref.getName(), false);

    refUpdate.setForceUpdate(force);//  w w  w . j  ava2s  . c  om

    return refUpdate.delete();
}

From source file:org.uberfire.java.nio.fs.jgit.util.commands.RemoveRemote.java

License:Apache License

public void execute() {
    try {/* w ww.  j a va 2  s  . c o m*/
        // AF-1715: Cleaning origin to prevent errors while importing the new generated repo.
        git.getRepository().getConfig().unsetSection("remote", remote);
        git.getRepository().getConfig().save();
        RefUpdate updateRef = git.getRepository().updateRef(ref, false);
        updateRef.setRefLogMessage(ref + " packed-ref deleted", false);
        updateRef.setForceUpdate(true);
        updateRef.delete();
    } catch (Exception e) {
        throw new GitException("Error when trying to remove remote", e);
    }
}

From source file:svnserver.repository.git.LayoutHelper.java

License:GNU General Public License

@NotNull
public static Ref initRepository(@NotNull Repository repository, String branch) throws IOException {
    Ref ref = repository.getRef(PREFIX_REF + branch);
    if (ref == null) {
        Ref old = repository.getRef(OLD_CACHE_REF);
        if (old != null) {
            final RefUpdate refUpdate = repository.updateRef(PREFIX_REF + branch);
            refUpdate.setNewObjectId(old.getObjectId());
            refUpdate.update();/*from w  ww. j  a v  a2s . c om*/
        }
    }
    if (ref == null) {
        final ObjectId revision = createFirstRevision(repository);
        final RefUpdate refUpdate = repository.updateRef(PREFIX_REF + branch);
        refUpdate.setNewObjectId(revision);
        refUpdate.update();
        ref = repository.getRef(PREFIX_REF + branch);
        if (ref == null) {
            throw new IOException("Can't initialize repository.");
        }
    }
    Ref old = repository.getRef(OLD_CACHE_REF);
    if (old != null) {
        final RefUpdate refUpdate = repository.updateRef(OLD_CACHE_REF);
        refUpdate.setForceUpdate(true);
        refUpdate.delete();
    }
    return ref;
}