本文整理汇总了Java中org.eclipse.jgit.lib.StoredConfig.save方法的典型用法代码示例。如果您正苦于以下问题:Java StoredConfig.save方法的具体用法?Java StoredConfig.save怎么用?Java StoredConfig.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.lib.StoredConfig
的用法示例。
在下文中一共展示了StoredConfig.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
private void execute() throws InvalidRemoteException, TransportException, GitAPIException, IOException {
setProxy();
CloneCommand cmd = Git.cloneRepository()
.setURI(config.getRemoteUrl());
if (config.getLocalPath() != "") {
cmd.setDirectory(new File(config.getLocalPath()));
}
Git git = cmd.call();
// Set proxy setting to repository config.
StoredConfig gitConfig = git.getRepository().getConfig();
gitConfig.setString("remote", "origin", "proxy", config.getProxyAddress());
gitConfig.save();
git.getRepository().close();
}
示例2: persistUser
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public static void persistUser (File root, GitUser author) throws GitException {
Repository repository = getRepository(root);
if (repository != null) {
try {
StoredConfig config = repository.getConfig();
config.setString("user", null, "name", author.getName()); //NOI18N
config.setString("user", null, "email", author.getEmailAddress()); //NOI18N
try {
config.save();
FileUtil.refreshFor(new File(GitUtils.getGitFolderForRoot(root), "config"));
} catch (IOException ex) {
throw new GitException(ex);
}
} finally {
repository.close();
}
}
}
示例3: testRemoteRepositoryHasNoCommitst
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Test(expected = MissingObjectException.class)
public void testRemoteRepositoryHasNoCommitst()
throws URISyntaxException, IOException, InvalidRemoteException, TransportException, GitAPIException, NoRepositorySelected {
gitAccess.setRepository(LOCAL_TEST_REPOSITPRY);
final StoredConfig config = gitAccess.getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(db2.getDirectory().toURI().toURL());
remoteConfig.addURI(uri);
remoteConfig.update(config);
config.save();
gitAccess.add(new FileStatus(GitChangeType.ADD, "test.txt"));
gitAccess.commit("file test added");
// throws missingObjectException
db2.resolve(gitAccess.getLastLocalCommit().getName() + "^{commit}");
}
示例4: test199443_GlobalIgnoreFile
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public void test199443_GlobalIgnoreFile () throws Exception {
File f = new File(new File(workDir, "nbproject"), "file");
f.getParentFile().mkdirs();
f.createNewFile();
File ignoreFile = new File(workDir.getParentFile(), "globalignore");
write(ignoreFile, ".DS_Store\n.svn\nnbproject\nnbproject/private\n");
Repository repo = getRepository(getLocalGitRepository());
StoredConfig cfg = repo.getConfig();
cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_EXCLUDESFILE, ignoreFile.getAbsolutePath());
cfg.save();
GitClient client = getClient(workDir);
assertEquals(Status.STATUS_IGNORED, client.getStatus(new File[] { f }, NULL_PROGRESS_MONITOR).get(f).getStatusIndexWC());
// now since the file is already ignored, no ignore file should be modified
assertEquals(0, client.ignore(new File[] { f }, NULL_PROGRESS_MONITOR).length);
// on the other hand, if .git/info/exclude reverts the effect of global excludes file, ignored file should be modified
File dotGitIgnoreFile = new File(new File(repo.getDirectory(), "info"), "exclude");
dotGitIgnoreFile.getParentFile().mkdirs();
write(dotGitIgnoreFile, "!/nbproject/");
assertEquals(Status.STATUS_ADDED, client.getStatus(new File[] { f }, NULL_PROGRESS_MONITOR).get(f).getStatusIndexWC());
assertEquals(dotGitIgnoreFile, client.ignore(new File[] { f }, NULL_PROGRESS_MONITOR)[0]);
assertEquals(Status.STATUS_IGNORED, client.getStatus(new File[] { f }, NULL_PROGRESS_MONITOR).get(f).getStatusIndexWC());
}
示例5: test199443_GlobalIgnoreFileOverwrite
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public void test199443_GlobalIgnoreFileOverwrite () throws Exception {
File f = new File(new File(workDir, "nbproject"), "file");
f.getParentFile().mkdirs();
f.createNewFile();
File ignoreFile = new File(workDir.getParentFile(), "globalignore");
Repository repo = getRepository(getLocalGitRepository());
StoredConfig cfg = repo.getConfig();
cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_EXCLUDESFILE, ignoreFile.getAbsolutePath());
cfg.save();
write(ignoreFile, "!nbproject");
GitClient client = getClient(workDir);
assertEquals(new File(workDir, Constants.GITIGNORE_FILENAME), client.ignore(new File[] { f }, NULL_PROGRESS_MONITOR)[0]);
assertEquals("/nbproject/file", read(new File(workDir, Constants.GITIGNORE_FILENAME)));
}
示例6: test199443_GlobalIgnoreFile
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public void test199443_GlobalIgnoreFile () throws Exception {
File f = new File(new File(workDir, "nbproject"), "file");
f.getParentFile().mkdirs();
f.createNewFile();
File ignoreFile = new File(workDir.getParentFile(), "globalignore");
write(ignoreFile, "nbproject");
Repository repo = getRepository(getLocalGitRepository());
StoredConfig cfg = repo.getConfig();
cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_EXCLUDESFILE, ignoreFile.getAbsolutePath());
cfg.save();
GitClient client = getClient(workDir);
assertEquals(Status.STATUS_IGNORED, client.getStatus(new File[] { f }, NULL_PROGRESS_MONITOR).get(f).getStatusIndexWC());
assertEquals(new File(workDir, Constants.GITIGNORE_FILENAME), client.unignore(new File[] { f }, NULL_PROGRESS_MONITOR)[0]);
write(new File(workDir, Constants.GITIGNORE_FILENAME), "/nbproject/file");
assertEquals(new File(workDir, Constants.GITIGNORE_FILENAME), client.unignore(new File[] { f }, NULL_PROGRESS_MONITOR)[0]);
assertEquals("!/nbproject/file", read(new File(workDir, Constants.GITIGNORE_FILENAME)));
}
示例7: doOK
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
/**
* Adds the remote as origin to the repository
*/
@Override
protected void doOK() {
super.doOK();
StoredConfig config;
try {
config = GitAccess.getInstance().getRepository().getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(remoteRepoTextField.getText());
remoteConfig.addURI(uri);
RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
remoteConfig.addFetchRefSpec(spec);
remoteConfig.update(config);
config.save();
} catch (NoRepositorySelected | URISyntaxException | IOException e) {
if (logger.isDebugEnabled()) {
logger.debug(e, e);
}
}
dispose();
}
示例8: testMergeBranchNoHeadYet_196837
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public void testMergeBranchNoHeadYet_196837 () throws Exception {
StoredConfig cfg = getRemoteRepository().getConfig();
cfg.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_BARE, false);
cfg.save();
File otherRepo = getRemoteRepository().getWorkTree();
File original = new File(otherRepo, "f");
GitClient clientOtherRepo = getClient(otherRepo);
write(original, "initial content");
clientOtherRepo.add(new File[] { original }, NULL_PROGRESS_MONITOR);
clientOtherRepo.commit(new File[] { original }, "initial commit", null, null, NULL_PROGRESS_MONITOR);
GitClient client = getClient(workDir);
Map<String, GitTransportUpdate> updates = client.fetch(otherRepo.toURI().toString(), Arrays.asList(new String[] { "+refs/heads/master:refs/remotes/origin/master" }), NULL_PROGRESS_MONITOR);
GitMergeResult result = client.merge("origin/master", NULL_PROGRESS_MONITOR);
assertEquals(MergeStatus.FAST_FORWARD, result.getMergeStatus());
assertEquals(Arrays.asList(new String[] { ObjectId.zeroId().getName(), updates.get("origin/master").getNewObjectId() }), Arrays.asList(result.getMergedCommits()));
}
示例9: testAddIgnoreExecutable
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public void testAddIgnoreExecutable () throws Exception {
if (isWindows()) {
// no reason to test on windows
return;
}
File f = new File(workDir, "f");
write(f, "hi, i am executable");
f.setExecutable(true);
File[] roots = { f };
GitClient client = getClient(workDir);
StoredConfig config = repository.getConfig();
config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_FILEMODE, false);
config.save();
// add should not set executable bit in index
add(roots);
Map<File, GitStatus> statuses = client.getStatus(roots, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, f, true, Status.STATUS_ADDED, Status.STATUS_NORMAL, Status.STATUS_ADDED, false);
// index should differ from wt
config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_FILEMODE, true);
config.save();
statuses = client.getStatus(roots, NULL_PROGRESS_MONITOR);
assertStatus(statuses, workDir, f, true, Status.STATUS_ADDED, Status.STATUS_MODIFIED, Status.STATUS_ADDED, false);
}
示例10: configureBranch
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
protected void configureBranch(Git git, String branch) {
// lets update the merge config
if (Strings.isNotBlank(branch)) {
StoredConfig config = git.getRepository().getConfig();
if (Strings.isNullOrBlank(config.getString("branch", branch, "remote")) || Strings.isNullOrBlank(config.getString("branch", branch, "merge"))) {
config.setString("branch", branch, "remote", getRemote());
config.setString("branch", branch, "merge", "refs/heads/" + branch);
try {
config.save();
} catch (IOException e) {
LOG.error("Failed to save the git configuration to " + basedir
+ " with branch " + branch + " on remote repo: " + remoteRepository + " due: " + e.getMessage() + ". This exception is ignored.", e);
}
}
}
}
示例11: clone
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public static void clone(String url, File target) throws GitAPIException, IOException
{
System.out.println( "Starting clone of " + url + " to " + target );
Git result = Git.cloneRepository().setURI( url ).setDirectory( target ).call();
try
{
StoredConfig config = result.getRepository().getConfig();
config.setBoolean( "core", null, "autocrlf", autocrlf );
config.save();
System.out.println( "Cloned git repository " + url + " to " + target.getAbsolutePath() + ". Current HEAD: " + commitHash( result ) );
} finally
{
result.close();
}
}
示例12: ifThereIsNoScmInfoAndNoRemoteBranchThenAnErrorIsThrown
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Test
public void ifThereIsNoScmInfoAndNoRemoteBranchThenAnErrorIsThrown()
throws GitAPIException, IOException, InterruptedException {
final TestProject testProject = TestProject.singleModuleProject();
final StoredConfig config = testProject.local.getRepository().getConfig();
config.unsetSection("remote", "origin");
config.save();
try {
testProject.mvnRelease("1");
Assert.fail("Should have failed");
} catch (final MavenExecutionException e) {
assertThat(e.output, oneOf(containsString("[ERROR] Remote tags could not be listed!")));
}
}
示例13: configureBranch
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public static void configureBranch(Git git, String branch, String origin, String remoteRepository) {
// lets update the merge config
if (!Strings.isNullOrBlank(branch)) {
StoredConfig config = git.getRepository().getConfig();
config.setString("branch", branch, "remote", origin);
config.setString("branch", branch, "merge", "refs/heads/" + branch);
config.setString("remote", origin, "url", remoteRepository);
config.setString("remote", origin, "fetch", "+refs/heads/*:refs/remotes/" + origin + "/*");
try {
config.save();
} catch (IOException e) {
LOG.error("Failed to save the git configuration to " + git.getRepository().getDirectory()
+ " with branch " + branch + " on " + origin + " remote repo: " + remoteRepository + " due: " + e.getMessage() + ". This exception is ignored.", e);
}
}
}
示例14: updateCoreIgnoreCaseSetting
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
private static void updateCoreIgnoreCaseSetting(@Nullable Git git) {
if (SystemInfo.isFileSystemCaseSensitive) {
return;
}
if (git == null) {
LOG.info("jgit.Git is null, the command should have failed. Not updating the settings.");
return;
}
StoredConfig config = git.getRepository().getConfig();
config.setString(ConfigConstants.CONFIG_CORE_SECTION, null, IGNORECASE_SETTING, Boolean.TRUE.toString());
try {
config.save();
}
catch (IOException e) {
LOG.info("Couldn't save config for " + git.getRepository().getDirectory().getPath(), e);
}
}
示例15: deleteRegistrations
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Override
public boolean deleteRegistrations(List<GitblitRegistration> list) {
boolean success = false;
try {
StoredConfig config = getConfig();
for (GitblitRegistration reg : list) {
config.unsetSection(SERVER, reg.name);
registrations.remove(reg.name);
}
config.save();
success = true;
} catch (Throwable t) {
Utils.showException(GitblitManager.this, t);
}
return success;
}