本文整理汇总了Java中org.eclipse.jgit.lib.ConfigConstants类的典型用法代码示例。如果您正苦于以下问题:Java ConfigConstants类的具体用法?Java ConfigConstants怎么用?Java ConfigConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigConstants类属于org.eclipse.jgit.lib包,在下文中一共展示了ConfigConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeDeletedBranches
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
private void removeDeletedBranches (Map<String, GitBranch> branches) {
Set<String> localBranches = new HashSet<>();
for (Map.Entry<String, GitBranch> b : branches.entrySet()) {
if (!b.getValue().isRemote() && !b.getKey().equals(GitBranch.NO_BRANCH)) {
localBranches.add(b.getKey());
}
}
if (!localBranches.equals(cachedBranches)) {
cachedBranches = localBranches;
List<String> toRemove = new ArrayList<>(config.getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION));
boolean save = false;
for (String branchName : toRemove) {
if (!localBranches.contains(branchName)) {
config.unsetSection(ConfigConstants.CONFIG_BRANCH_SECTION, branchName);
save = true;
}
}
if (save) {
save();
}
}
}
示例2: run
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
@Override
protected void run () throws GitException {
Repository repository = getRepository();
StoredConfig config = repository.getConfig();
config.unsetSection(ConfigConstants.CONFIG_REMOTE_SECTION, remote);
Set<String> subSections = config.getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION);
for (String subSection : subSections) {
if (remote.equals(config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, subSection, ConfigConstants.CONFIG_KEY_REMOTE))) {
config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, subSection, ConfigConstants.CONFIG_KEY_REMOTE);
config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, subSection, ConfigConstants.CONFIG_KEY_MERGE);
}
}
try {
config.save();
} catch (IOException ex) {
throw new GitException(ex);
}
}
示例3: getTrackedBranch
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
public static GitBranch getTrackedBranch (Config config, String branchName, Map<String, GitBranch> allBranches) {
String remoteName = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_REMOTE);
String trackedBranchName = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName, ConfigConstants.CONFIG_KEY_MERGE);
if (trackedBranchName != null) {
if (trackedBranchName.startsWith(Constants.R_HEADS)) {
trackedBranchName = trackedBranchName.substring(Constants.R_HEADS.length());
} else if (trackedBranchName.startsWith(Constants.R_REMOTES)) {
trackedBranchName = trackedBranchName.substring(Constants.R_REMOTES.length());
}
}
if (trackedBranchName == null) {
return null;
} else {
if (remoteName != null && ".".equals(remoteName)) { //NOI18N
remoteName = ""; //NOI18N
} else {
remoteName = remoteName + "/"; //NOI18N
}
return allBranches.get(remoteName + trackedBranchName);
}
}
示例4: test199443_GlobalIgnoreFile
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的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.ConfigConstants; //导入依赖的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: testRemoteTrackingNoRemoteSet
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
public void testRemoteTrackingNoRemoteSet () throws GitException {
GitClient client = getClient(workDir);
File f = new File(workDir, "f");
add(f);
client.commit(new File[] { f }, "init commit", null, null, NULL_PROGRESS_MONITOR);
// push to remote
String remoteUri = getRemoteRepository().getWorkTree().toURI().toString();
client.push(remoteUri,
Arrays.asList("refs/heads/master:refs/heads/master"),
Arrays.asList("+refs/heads/*:refs/remotes/origin/*"),
NULL_PROGRESS_MONITOR);
Map<String, GitBranch> branches = client.getBranches(true, NULL_PROGRESS_MONITOR);
assertTrue(branches.containsKey("origin/master"));
assertNull(branches.get("master").getTrackedBranch());
// set tracking
GitBranch b = client.setUpstreamBranch("master", "origin/master", NULL_PROGRESS_MONITOR);
assertEquals("origin/master", b.getTrackedBranch().getName());
Config cfg = repository.getConfig();
assertEquals(".", cfg.getString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_REMOTE));
assertEquals("refs/remotes/origin/master", cfg.getString(ConfigConstants.CONFIG_BRANCH_SECTION, "master", ConfigConstants.CONFIG_KEY_MERGE));
}
示例7: testDeleteUntrackedLocalBranch
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
public void testDeleteUntrackedLocalBranch () throws Exception {
File f = new File(workDir, "f");
File[] files = { f };
write(f, "init");
add(files);
commit(files);
GitClient client = getClient(workDir);
GitBranch b = client.createBranch(BRANCH_NAME, "master", NULL_PROGRESS_MONITOR);
Map<String, GitBranch> branches = client.getBranches(false, NULL_PROGRESS_MONITOR);
assertEquals(2, branches.size());
assertNotNull(branches.get(BRANCH_NAME));
assertEquals(0, repository.getConfig().getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION).size());
// delete branch
client.deleteBranch(BRANCH_NAME, false, NULL_PROGRESS_MONITOR);
branches = client.getBranches(false, NULL_PROGRESS_MONITOR);
assertEquals(1, branches.size());
assertNull(branches.get(BRANCH_NAME));
}
示例8: testMergeBranchNoHeadYet_196837
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的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.ConfigConstants; //导入依赖的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: test199443_GlobalIgnoreFile
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的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)));
}
示例11: remoteList
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
@Override
public List<Remote> remoteList(String remoteName, boolean verbose) throws GitException {
StoredConfig config = repository.getConfig();
Set<String> remoteNames =
new HashSet<>(config.getSubsections(ConfigConstants.CONFIG_KEY_REMOTE));
if (remoteName != null && remoteNames.contains(remoteName)) {
remoteNames.clear();
remoteNames.add(remoteName);
}
List<Remote> result = new ArrayList<>(remoteNames.size());
for (String remote : remoteNames) {
try {
List<URIish> uris = new RemoteConfig(config, remote).getURIs();
result.add(
newDto(Remote.class)
.withName(remote)
.withUrl(uris.isEmpty() ? null : uris.get(0).toString()));
} catch (URISyntaxException exception) {
throw new GitException(exception.getMessage(), exception);
}
}
return result;
}
示例12: logGcConfiguration
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
private static void logGcConfiguration(
Project.NameKey projectName, Repository repo, boolean aggressive) {
StringBuilder b = new StringBuilder();
Config cfg = repo.getConfig();
b.append("gc.aggressive=").append(aggressive).append("; ");
b.append(formatConfigValues(cfg, ConfigConstants.CONFIG_GC_SECTION, null));
for (String subsection : cfg.getSubsections(ConfigConstants.CONFIG_GC_SECTION)) {
b.append(formatConfigValues(cfg, ConfigConstants.CONFIG_GC_SECTION, subsection));
}
if (b.length() == 0) {
b.append("no set");
}
logGcInfo(projectName, "gc config: " + b.toString());
logGcInfo(projectName, "pack config: " + (new PackConfig(repo)).toString());
}
示例13: updateCoreIgnoreCaseSetting
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的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);
}
}
示例14: test_clone_refspecs
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
public void test_clone_refspecs() throws Exception {
List<RefSpec> refspecs = Lists.newArrayList(
new RefSpec("+refs/heads/master:refs/remotes/origin/master"),
new RefSpec("+refs/heads/1.4.x:refs/remotes/origin/1.4.x")
);
w.git.clone_().url(localMirror()).refspecs(refspecs).repositoryName("origin").execute();
w.git.withRepository((Repository repo, VirtualChannel channel) -> {
String[] fetchRefSpecs = repo.getConfig().getStringList(ConfigConstants.CONFIG_REMOTE_SECTION, Constants.DEFAULT_REMOTE_NAME, "fetch");
assertEquals("Expected 2 refspecs", 2, fetchRefSpecs.length);
assertEquals("Incorrect refspec 1", "+refs/heads/master:refs/remotes/origin/master", fetchRefSpecs[0]);
assertEquals("Incorrect refspec 2", "+refs/heads/1.4.x:refs/remotes/origin/1.4.x", fetchRefSpecs[1]);
return null;
});
Set<Branch> remoteBranches = w.git.getRemoteBranches();
assertBranchesExist(remoteBranches, "origin/master");
assertBranchesExist(remoteBranches, "origin/1.4.x");
assertEquals(2, remoteBranches.size());
}
示例15: setAutoSyncBranch
import org.eclipse.jgit.lib.ConfigConstants; //导入依赖的package包/类
public void setAutoSyncBranch (String branch, boolean autoSync) {
boolean oldVal = getAutoSyncBranch(branch);
if (oldVal != autoSync) {
if (autoSync) {
config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, branch, CONFIG_AUTO_SYNC, autoSync);
} else {
config.unset(ConfigConstants.CONFIG_BRANCH_SECTION, branch, CONFIG_AUTO_SYNC);
if (config.getNames(ConfigConstants.CONFIG_BRANCH_SECTION, branch).isEmpty()) {
config.unsetSection(ConfigConstants.CONFIG_BRANCH_SECTION, branch);
}
}
save();
}
}