当前位置: 首页>>代码示例>>Java>>正文


Java Repository.getConfig方法代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.Repository.getConfig方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.getConfig方法的具体用法?Java Repository.getConfig怎么用?Java Repository.getConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.lib.Repository的用法示例。


在下文中一共展示了Repository.getConfig方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isUserSetup

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
public static boolean isUserSetup (File root) {
    Repository repository = getRepository(root);
    boolean userExists = true;
    if (repository != null) {
        try {
            StoredConfig config = repository.getConfig();
            String name = config.getString("user", null, "name"); //NOI18N
            String email = config.getString("user", null, "email"); //NOI18N
            if (name == null || name.isEmpty() || email == null || email.isEmpty()) {
                userExists = false;
            }
        } finally {
            repository.close();
        }
    }
    return userExists;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JGitUtils.java

示例2: persistUser

import org.eclipse.jgit.lib.Repository; //导入方法依赖的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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JGitUtils.java

示例3: run

import org.eclipse.jgit.lib.Repository; //导入方法依赖的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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:RemoveRemoteCommand.java

示例4: test199443_GlobalIgnoreFile

import org.eclipse.jgit.lib.Repository; //导入方法依赖的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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:IgnoreTest.java

示例5: test199443_GlobalIgnoreFileOverwrite

import org.eclipse.jgit.lib.Repository; //导入方法依赖的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)));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:IgnoreTest.java

示例6: test199443_GlobalIgnoreFile

import org.eclipse.jgit.lib.Repository; //导入方法依赖的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)));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:UnignoreTest.java

示例7: setupRebaseFlag

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
private void setupRebaseFlag (Repository repository) throws IOException {
    Ref baseRef = repository.getRef(revision);
    if (baseRef != null && baseRef.getName().startsWith(Constants.R_REMOTES)) {
        StoredConfig config = repository.getConfig();
        String autosetupRebase = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION,
                null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE);
        boolean rebase = ConfigConstants.CONFIG_KEY_ALWAYS.equals(autosetupRebase)
                || ConfigConstants.CONFIG_KEY_REMOTE.equals(autosetupRebase);
        if (rebase && !config.getNames(ConfigConstants.CONFIG_BRANCH_SECTION, branchName).isEmpty()) {
            config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
                    ConfigConstants.CONFIG_KEY_REBASE, rebase);
            config.save();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:CreateBranchCommand.java

示例8: run

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
@Override
protected void run () throws GitException {
    Repository repository = getRepository();
    Map<String, Ref> refs;
    try {
        refs = repository.getAllRefs();
    } catch (IllegalArgumentException ex) {
        throw new GitException("Corrupted repository metadata at " + repository.getWorkTree().getAbsolutePath(), ex); //NOI18N
    }
    Ref head = refs.get(Constants.HEAD);
    branches = new LinkedHashMap<String, GitBranch>();
    Config cfg = repository.getConfig();
    if (head != null) {
        String current = head.getLeaf().getName();
        if (current.equals(Constants.HEAD)) {
            String name = GitBranch.NO_BRANCH;
            branches.put(name, getClassFactory().createBranch(name, false, true, head.getLeaf().getObjectId()));
        }
        branches.putAll(getRefs(refs.values(), Constants.R_HEADS, false, current, cfg));
    }
    Map<String, GitBranch> allBranches = getRefs(refs.values(), Constants.R_REMOTES, true, null, cfg);
    allBranches.putAll(branches);
    setupTracking(branches, allBranches, repository.getConfig());
    if (all) {
        branches.putAll(allBranches);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ListBranchCommand.java

示例9: run

import org.eclipse.jgit.lib.Repository; //导入方法依赖的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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:SetUpstreamBranchCommand.java

示例10: setupRebaseFlag

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
private void setupRebaseFlag (Repository repository) throws IOException {
    StoredConfig config = repository.getConfig();
    String autosetupRebase = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION,
            null, ConfigConstants.CONFIG_KEY_AUTOSETUPREBASE);
    boolean rebase = ConfigConstants.CONFIG_KEY_ALWAYS.equals(autosetupRebase)
            || ConfigConstants.CONFIG_KEY_REMOTE.equals(autosetupRebase);
    if (rebase) {
        config.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION, localBranchName,
                ConfigConstants.CONFIG_KEY_REBASE, rebase);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:SetUpstreamBranchCommand.java

示例11: enableInsecureReceiving

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
/**
 * To allow performing push operations from the cloned repository to remote (served by this server) let's
 * skip authorization for HTTP.
 */
private void enableInsecureReceiving(Repository repository) {
    final StoredConfig config = repository.getConfig();
    config.setBoolean("http", null, "receivepack", true);
    try {
        config.save();
    } catch (IOException e) {
        throw new RuntimeException("Unable to save http.receivepack=true config", e);
    }
}
 
开发者ID:arquillian,项目名称:smart-testing,代码行数:14,代码来源:EmbeddedHttpGitServer.java

示例12: bindLocalToRemote

import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
/**
 * Binds the local repository to the remote one.
 * 
 * @param localRepository The local repository.
 * @param remoteRepo The remote repository.
 * 
 * @throws NoRepositorySelected
 * @throws URISyntaxException
 * @throws MalformedURLException
 * @throws IOException
 */
protected void bindLocalToRemote(Repository localRepository, Repository remoteRepo)
    throws NoRepositorySelected, URISyntaxException, MalformedURLException, IOException {
  
  StoredConfig config = localRepository.getConfig();
  RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
  URIish uri = new URIish(remoteRepo.getDirectory().toURI().toURL());
  remoteConfig.addURI(uri);
  RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
  remoteConfig.addFetchRefSpec(spec);
  remoteConfig.update(config);
  config.save();
  
  remoteRepos.add(remoteRepo);
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:26,代码来源:GitTestBase.java


注:本文中的org.eclipse.jgit.lib.Repository.getConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。