本文整理汇总了Java中org.eclipse.jgit.lib.StoredConfig.unsetSection方法的典型用法代码示例。如果您正苦于以下问题:Java StoredConfig.unsetSection方法的具体用法?Java StoredConfig.unsetSection怎么用?Java StoredConfig.unsetSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.lib.StoredConfig
的用法示例。
在下文中一共展示了StoredConfig.unsetSection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的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);
}
}
示例2: 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!")));
}
}
示例3: 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;
}
示例4: ifThereIsNoRemoteButTheScmDetailsArePresentThenThisIsUsed
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Test
public void ifThereIsNoRemoteButTheScmDetailsArePresentThenThisIsUsed()
throws GitAPIException, IOException, InterruptedException {
final TestProject testProject = TestProject.moduleWithScmTag();
final StoredConfig config = testProject.local.getRepository().getConfig();
config.unsetSection("remote", "origin");
config.save();
testProject.mvnRelease("1");
}
示例5: ifThereIsNoScmInfoAndNoRemoteBranchThenAnErrorIsThrown
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Test
public void ifThereIsNoScmInfoAndNoRemoteBranchThenAnErrorIsThrown() throws GitAPIException, IOException, InterruptedException {
TestProject testProject = TestProject.singleModuleProject();
StoredConfig config = testProject.local.getRepository().getConfig();
config.unsetSection("remote", "origin");
config.save();
try {
testProject.mvnRelease("1");
Assert.fail("Should have failed");
} catch (MavenExecutionException e) {
assertThat(e.output, oneOf(containsString("[ERROR] origin: not found.")));
}
}
示例6: ifThereIsNoRemoteButTheScmDetailsArePresentThenThisIsUsed
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Test
public void ifThereIsNoRemoteButTheScmDetailsArePresentThenThisIsUsed() throws GitAPIException, IOException, InterruptedException {
TestProject testProject = TestProject.moduleWithScmTag();
StoredConfig config = testProject.local.getRepository().getConfig();
config.unsetSection("remote", "origin");
config.save();
testProject.mvnRelease("1");
}
示例7: usesThePassedInScmUrlToFindRemote
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Test
public void usesThePassedInScmUrlToFindRemote() throws Exception {
String remote = scmUrlToRemote(dirToGitScmReference(project.originDir));
LocalGitRepo repo = new LocalGitRepo(project.local, new RemoteTagFetcher(project.local, remote),
new LocalTagPusher(project.local));
tag(project.origin, "some-tag");
StoredConfig config = project.local.getRepository().getConfig();
config.unsetSection("remote", "origin");
config.save();
assertThat(repo.tagsFrom(tags("blah", "some-tag")), equalTo(asList("some-tag")));
}
示例8: remoteDelete
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Override
public void remoteDelete(String name) throws GitException {
StoredConfig config = repository.getConfig();
Set<String> remoteNames = config.getSubsections(ConfigConstants.CONFIG_KEY_REMOTE);
if (!remoteNames.contains(name)) {
throw new GitException("error: Could not remove config section 'remote." + name + "'");
}
config.unsetSection(ConfigConstants.CONFIG_REMOTE_SECTION, name);
Set<String> branches = config.getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION);
for (String branch : branches) {
String r =
config.getString(
ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_REMOTE);
if (name.equals(r)) {
config.unset(
ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_REMOTE);
config.unset(
ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants.CONFIG_KEY_MERGE);
List<Branch> remoteBranches = branchList(LIST_REMOTE);
for (Branch remoteBranch : remoteBranches) {
if (remoteBranch.getDisplayName().startsWith(name)) {
branchDelete(remoteBranch.getName(), true);
}
}
}
}
try {
config.save();
} catch (IOException exception) {
throw new GitException(exception.getMessage(), exception);
}
}
示例9: saveRegistration
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Override
public boolean saveRegistration(String name, GitblitRegistration reg) {
try {
StoredConfig config = getConfig();
if (!StringUtils.isEmpty(name) && !name.equals(reg.name)) {
// delete old registration
registrations.remove(name);
config.unsetSection(SERVER, name);
}
// update registration
config.setString(SERVER, reg.name, "url", reg.url);
config.setString(SERVER, reg.name, "account", reg.account);
if (reg.savePassword) {
config.setString(SERVER, reg.name, "password",
Base64.encodeBytes(new String(reg.password).getBytes("UTF-8")));
} else {
config.setString(SERVER, reg.name, "password", "");
}
if (reg.lastLogin != null) {
config.setString(SERVER, reg.name, "lastLogin", dateFormat.format(reg.lastLogin));
}
// serialize the feed definitions
List<String> definitions = new ArrayList<String>();
for (FeedModel feed : reg.feeds) {
definitions.add(feed.toString());
}
if (definitions.size() > 0) {
config.setStringList(SERVER, reg.name, FEED, definitions);
}
config.save();
return true;
} catch (Throwable t) {
Utils.showException(GitblitManager.this, t);
}
return false;
}
示例10: initializeConfiguration
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@Before
public void initializeConfiguration() throws Exception{
Repository r = GitBlitSuite.getHelloworldRepository();
StoredConfig config = r.getConfig();
config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, "commitMessageRegEx", "\\d");
config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, "anotherProperty", "Hello");
config.save();
}
示例11: teardownConfiguration
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
@After
public void teardownConfiguration() throws Exception {
Repository r = GitBlitSuite.getHelloworldRepository();
StoredConfig config = r.getConfig();
config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
config.save();
}
示例12: removeRemote
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
public void removeRemote(String remote) throws IOException {
try {
StoredConfig config = getStoredConfig();
Set<String> remoteNames = config.getSubsections("remote");
if (!remoteNames.contains(remote)) {
throw new IOException(String.format("Remote %s does not exist.", remote));
}
config.unsetSection("remote", remote);
config.save();
mRemotes.remove(remote);
} catch (StopTaskException e) {
}
}
示例13: updateConfiguration
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
/**
* Updates the Gitblit configuration for the specified repository.
*
* @param r
* the Git repository
* @param repository
* the Gitblit repository model
*/
public void updateConfiguration(Repository r, RepositoryModel repository) {
StoredConfig config = r.getConfig();
config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description);
config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useTickets", repository.useTickets);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useDocs", repository.useDocs);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useIncrementalPushTags", repository.useIncrementalPushTags);
if (StringUtils.isEmpty(repository.incrementalPushTagPrefix) ||
repository.incrementalPushTagPrefix.equals(settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r"))) {
config.unset(Constants.CONFIG_GITBLIT, null, "incrementalPushTagPrefix");
} else {
config.setString(Constants.CONFIG_GITBLIT, null, "incrementalPushTagPrefix", repository.incrementalPushTagPrefix);
}
config.setBoolean(Constants.CONFIG_GITBLIT, null, "allowForks", repository.allowForks);
config.setString(Constants.CONFIG_GITBLIT, null, "accessRestriction", repository.accessRestriction.name());
config.setString(Constants.CONFIG_GITBLIT, null, "authorizationControl", repository.authorizationControl.name());
config.setBoolean(Constants.CONFIG_GITBLIT, null, "verifyCommitter", repository.verifyCommitter);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "showRemoteBranches", repository.showRemoteBranches);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFrozen", repository.isFrozen);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "showReadme", repository.showReadme);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSizeCalculation", repository.skipSizeCalculation);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSummaryMetrics", repository.skipSummaryMetrics);
config.setString(Constants.CONFIG_GITBLIT, null, "federationStrategy",
repository.federationStrategy.name());
config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFederated", repository.isFederated);
config.setString(Constants.CONFIG_GITBLIT, null, "gcThreshold", repository.gcThreshold);
if (repository.gcPeriod == settings.getInteger(Keys.git.defaultGarbageCollectionPeriod, 7)) {
// use default from config
config.unset(Constants.CONFIG_GITBLIT, null, "gcPeriod");
} else {
config.setInt(Constants.CONFIG_GITBLIT, null, "gcPeriod", repository.gcPeriod);
}
if (repository.lastGC != null) {
config.setString(Constants.CONFIG_GITBLIT, null, "lastGC", new SimpleDateFormat(Constants.ISO8601).format(repository.lastGC));
}
if (repository.maxActivityCommits == settings.getInteger(Keys.web.maxActivityCommits, 0)) {
// use default from config
config.unset(Constants.CONFIG_GITBLIT, null, "maxActivityCommits");
} else {
config.setInt(Constants.CONFIG_GITBLIT, null, "maxActivityCommits", repository.maxActivityCommits);
}
updateList(config, "federationSets", repository.federationSets);
updateList(config, "preReceiveScript", repository.preReceiveScripts);
updateList(config, "postReceiveScript", repository.postReceiveScripts);
updateList(config, "mailingList", repository.mailingLists);
updateList(config, "indexBranch", repository.indexedBranches);
updateList(config, "metricAuthorExclusions", repository.metricAuthorExclusions);
// User Defined Properties
if (repository.customFields != null) {
if (repository.customFields.size() == 0) {
// clear section
config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
} else {
for (Entry<String, String> property : repository.customFields.entrySet()) {
// set field
String key = property.getKey();
String value = property.getValue();
config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, key, value);
}
}
}
try {
config.save();
} catch (IOException e) {
logger.error("Failed to save repository config!", e);
}
}
示例14: updateConfiguration
import org.eclipse.jgit.lib.StoredConfig; //导入方法依赖的package包/类
/**
* Updates the Gitblit configuration for the specified repository.
*
* @param r
* the Git repository
* @param repository
* the Gitblit repository model
*/
public void updateConfiguration(Repository r, RepositoryModel repository) {
StoredConfig config = r.getConfig();
config.setString(Constants.CONFIG_GITBLIT, null, "description", repository.description);
config.setString(Constants.CONFIG_GITBLIT, null, "owner", ArrayUtils.toString(repository.owners));
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useTickets", repository.useTickets);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useDocs", repository.useDocs);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "useIncrementalPushTags", repository.useIncrementalPushTags);
if (StringUtils.isEmpty(repository.incrementalPushTagPrefix) ||
repository.incrementalPushTagPrefix.equals(settings.getString(Keys.git.defaultIncrementalPushTagPrefix, "r"))) {
config.unset(Constants.CONFIG_GITBLIT, null, "incrementalPushTagPrefix");
} else {
config.setString(Constants.CONFIG_GITBLIT, null, "incrementalPushTagPrefix", repository.incrementalPushTagPrefix);
}
config.setBoolean(Constants.CONFIG_GITBLIT, null, "allowForks", repository.allowForks);
config.setString(Constants.CONFIG_GITBLIT, null, "accessRestriction", repository.accessRestriction.name());
config.setString(Constants.CONFIG_GITBLIT, null, "authorizationControl", repository.authorizationControl.name());
config.setBoolean(Constants.CONFIG_GITBLIT, null, "verifyCommitter", repository.verifyCommitter);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "showRemoteBranches", repository.showRemoteBranches);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFrozen", repository.isFrozen);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "showReadme", repository.showReadme);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSizeCalculation", repository.skipSizeCalculation);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSummaryMetrics", repository.skipSummaryMetrics);
config.setString(Constants.CONFIG_GITBLIT, null, "federationStrategy",
repository.federationStrategy.name());
config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFederated", repository.isFederated);
config.setString(Constants.CONFIG_GITBLIT, null, "gcThreshold", repository.gcThreshold);
if (repository.gcPeriod == settings.getInteger(Keys.git.defaultGarbageCollectionPeriod, 7)) {
// use default from config
config.unset(Constants.CONFIG_GITBLIT, null, "gcPeriod");
} else {
config.setInt(Constants.CONFIG_GITBLIT, null, "gcPeriod", repository.gcPeriod);
}
if (repository.lastGC != null) {
config.setString(Constants.CONFIG_GITBLIT, null, "lastGC", new SimpleDateFormat(Constants.ISO8601).format(repository.lastGC));
}
if (repository.maxActivityCommits == settings.getInteger(Keys.web.maxActivityCommits, 0)) {
// use default from config
config.unset(Constants.CONFIG_GITBLIT, null, "maxActivityCommits");
} else {
config.setInt(Constants.CONFIG_GITBLIT, null, "maxActivityCommits", repository.maxActivityCommits);
}
updateList(config, "federationSets", repository.federationSets);
updateList(config, "preReceiveScript", repository.preReceiveScripts);
updateList(config, "postReceiveScript", repository.postReceiveScripts);
updateList(config, "mailingList", repository.mailingLists);
updateList(config, "indexBranch", repository.indexedBranches);
// User Defined Properties
if (repository.customFields != null) {
if (repository.customFields.size() == 0) {
// clear section
config.unsetSection(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS);
} else {
for (Entry<String, String> property : repository.customFields.entrySet()) {
// set field
String key = property.getKey();
String value = property.getValue();
config.setString(Constants.CONFIG_GITBLIT, Constants.CONFIG_CUSTOM_FIELDS, key, value);
}
}
}
try {
config.save();
} catch (IOException e) {
logger.error("Failed to save repository config!", e);
}
}