Example usage for org.eclipse.jgit.lib StoredConfig save

List of usage examples for org.eclipse.jgit.lib StoredConfig save

Introduction

In this page you can find the example usage for org.eclipse.jgit.lib StoredConfig save.

Prototype

public abstract void save() throws IOException;

Source Link

Document

Save the configuration to the persistent store.

Usage

From source file:sh.isaac.provider.sync.git.SyncServiceGIT.java

License:Apache License

/**
 * Relink remote./*from w w w  . j  a  v a  2  s  .  c o  m*/
 *
 * @param remoteAddress the remote address
 * @param username the username
 * @param password the password
 * @throws IllegalArgumentException the illegal argument exception
 * @throws IOException Signals that an I/O exception has occurred.
 * @see sh.isaac.api.sync.SyncFiles#relinkRemote(java.lang.String, java.lang.String, java.lang.String)
 */
@Override
public void relinkRemote(String remoteAddress, String username, char[] password)
        throws IllegalArgumentException, IOException {
    try (Git git = getGit()) {
        LOG.debug("Configuring remote URL and fetch defaults to {}", remoteAddress);

        final StoredConfig sc = git.getRepository().getConfig();

        sc.setString("remote", "origin", "url", remoteAddress);
        sc.setString("remote", "origin", "fetch", "+refs/heads/*:refs/remotes/origin/*");
        sc.save();
    }
}