本文整理匯總了Java中org.eclipse.jgit.lib.StoredConfig.setString方法的典型用法代碼示例。如果您正苦於以下問題:Java StoredConfig.setString方法的具體用法?Java StoredConfig.setString怎麽用?Java StoredConfig.setString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jgit.lib.StoredConfig
的用法示例。
在下文中一共展示了StoredConfig.setString方法的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: 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());
}
示例4: 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)));
}
示例5: 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)));
}
示例6: 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);
}
}
}
}
示例7: 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);
}
}
}
示例8: 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);
}
}
示例9: setRemote
import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
public void setRemote(String remote, String url) throws IOException {
try {
StoredConfig config = getStoredConfig();
Set<String> remoteNames = config.getSubsections("remote");
if (remoteNames.contains(remote)) {
throw new IOException(String.format(
"Remote %s already exists.", remote));
}
config.setString("remote", remote, "url", url);
String fetch = String.format("+refs/heads/*:refs/remotes/%s/*",
remote);
config.setString("remote", remote, "fetch", fetch);
config.save();
mRemotes.add(remote);
} catch (StopTaskException e) {
}
}
示例10: createRepository
import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
/** 저장소 생성함.
* @throws Exception
*/
public boolean createRepository(){
try {
git.init().setBare(true).setDirectory(new File(this.path)).call();
StoredConfig config = localRepo.getConfig();
config.setString("http", null, "receivepack", "true");
config.save();
}catch(Exception e) {
System.err.println(e.getMessage());
return false;
}
return true;
}
示例11: run
import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
@Override
protected void run () throws GitException {
Repository repository = getRepository();
try {
Ref ref = repository.getRef(trackedBranchName);
if (ref == null) {
throw new GitException(MessageFormat.format(Utils.getBundle(SetUpstreamBranchCommand.class)
.getString("MSG_Error_UpdateTracking_InvalidReference"), trackedBranchName)); //NOI18N)
}
String remote = null;
String branchName = ref.getName();
StoredConfig config = repository.getConfig();
if (branchName.startsWith(Constants.R_REMOTES)) {
String[] elements = branchName.split("/", 4);
remote = elements[2];
if (config.getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION).contains(remote)) {
branchName = Constants.R_HEADS + elements[3];
setupRebaseFlag(repository);
} else {
// remote not yet set
remote = null;
}
}
if (remote == null) {
remote = "."; //NOI18N
}
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName,
ConfigConstants.CONFIG_KEY_REMOTE, remote);
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName,
ConfigConstants.CONFIG_KEY_MERGE, branchName);
config.save();
} catch (IOException ex) {
throw new GitException(ex);
}
ListBranchCommand branchCmd = new ListBranchCommand(repository, getClassFactory(), false, new DelegatingGitProgressMonitor(monitor));
branchCmd.run();
Map<String, GitBranch> branches = branchCmd.getBranches();
branch = branches.get(localBranchName);
}
示例12: testCreateBranchWithRebase
import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
public void testCreateBranchWithRebase () throws Exception {
final File otherWT = new File(workDir.getParentFile(), "repo2");
GitClient client = getClient(otherWT);
client.init(NULL_PROGRESS_MONITOR);
File f = new File(otherWT, "f");
write(f, "init");
client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
client = getClient(workDir);
client.setRemote(new GitRemoteConfig("origin",
Arrays.asList(new String[] { otherWT.getAbsolutePath() }),
Arrays.asList(new String[] { otherWT.getAbsolutePath() }),
Arrays.asList(new String[] { "refs/heads/*:refs/remotes/origin/*" }),
Arrays.asList(new String[] { "refs/remotes/origin/*:refs/heads/*" })), NULL_PROGRESS_MONITOR);
client.fetch("origin", NULL_PROGRESS_MONITOR);
StoredConfig config = repository.getConfig();
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE, ConfigConstants.CONFIG_KEY_NEVER);
config.save();
GitBranch b = client.createBranch(BRANCH_NAME, "origin/master", NULL_PROGRESS_MONITOR);
assertFalse(repository.getConfig().getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, BRANCH_NAME, ConfigConstants.CONFIG_KEY_REBASE, false));
client.deleteBranch(BRANCH_NAME, true, NULL_PROGRESS_MONITOR);
config = repository.getConfig();
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE, ConfigConstants.CONFIG_KEY_REMOTE);
config.save();
b = client.createBranch(BRANCH_NAME, "origin/master", NULL_PROGRESS_MONITOR);
assertTrue(repository.getConfig().getBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, BRANCH_NAME, ConfigConstants.CONFIG_KEY_REBASE, false));
}
示例13: testBranchTracking
import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
public void testBranchTracking () throws Exception {
final File otherWT = new File(workDir.getParentFile(), "repo2");
GitClient client = getClient(otherWT);
client.init(NULL_PROGRESS_MONITOR);
File f = new File(otherWT, "f");
write(f, "init");
client.add(new File[] { f }, NULL_PROGRESS_MONITOR);
client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
client = getClient(workDir);
client.setRemote(new GitRemoteConfig("origin",
Arrays.asList(otherWT.getAbsolutePath()),
Arrays.asList(otherWT.getAbsolutePath()),
Arrays.asList("+refs/heads/*:refs/remotes/origin/*"), Collections.<String>emptyList()), NULL_PROGRESS_MONITOR);
client.fetch("origin", NULL_PROGRESS_MONITOR);
GitBranch b = client.createBranch(Constants.MASTER, "origin/master", NULL_PROGRESS_MONITOR);
assertEquals("origin/master", b.getTrackedBranch().getName());
assertTrue(b.getTrackedBranch().isRemote());
client.checkoutRevision(Constants.MASTER, true, NULL_PROGRESS_MONITOR);
b = client.createBranch("nova1", Constants.MASTER, NULL_PROGRESS_MONITOR);
assertNull(b.getTrackedBranch());
StoredConfig cfg = repository.getConfig();
cfg.setString(ConfigConstants.CONFIG_BRANCH_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOSETUPMERGE, "always");
cfg.save();
b = client.createBranch("nova2", Constants.MASTER, NULL_PROGRESS_MONITOR);
assertEquals("master", b.getTrackedBranch().getName());
assertFalse(b.getTrackedBranch().isRemote());
// list branches
Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
b = branches.get(Constants.MASTER);
assertEquals("origin/master", b.getTrackedBranch().getName());
assertTrue(b.getTrackedBranch().isRemote());
b = branches.get("origin/master");
assertNull(b.getTrackedBranch());
}
示例14: testBlameMixedLineEndings
import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
public void testBlameMixedLineEndings () throws Exception {
File f = new File(workDir, "f");
String content = "";
for (int i = 0; i < 10000; ++i) {
content += i + "\r\n";
}
write(f, content);
// lets turn autocrlf on
StoredConfig cfg = repository.getConfig();
cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, "true");
cfg.save();
File[] files = new File[] { f };
GitClient client = getClient(workDir);
client.add(files, NULL_PROGRESS_MONITOR);
GitRevisionInfo info = client.commit(files, "commit", null, null, NULL_PROGRESS_MONITOR);
content = content.replaceFirst("0", "01");
write(f, content);
// it should be up to date again
org.eclipse.jgit.api.BlameCommand cmd = new Git(repository).blame();
cmd.setFilePath("f");
BlameResult blameResult = cmd.call();
assertEquals(info.getRevision(), blameResult.getSourceCommit(1).getName());
GitBlameResult res = client.blame(f, null, NULL_PROGRESS_MONITOR);
assertNull(res.getLineDetails(0));
assertLineDetails(f, 1, info.getRevision(), info.getAuthor(), info.getCommitter(), res.getLineDetails(1));
// without autocrlf it should all be modified
cfg.setString(ConfigConstants.CONFIG_CORE_SECTION, null, ConfigConstants.CONFIG_KEY_AUTOCRLF, "false");
cfg.save();
res = client.blame(f, null, NULL_PROGRESS_MONITOR);
assertNull(res.getLineDetails(1));
}
示例15: setUrl
import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
void setUrl(String url, String remote) {
if (url != null && url.length() > 0) {
StoredConfig config = repo.getRepository().getConfig();
config.setString("remote", remote, "url", url);
try {
config.save();
} catch (IOException ex) {
throw new RuntimeException("Unable to save repository configuration", ex);
}
}
}