Java 类org.eclipse.jgit.lib.Config 实例源码

项目:oxygen-git-plugin    文件:GitAccess.java   
/**
 * Gets the host name from the repositoryURL
 * 
 * @return The host name. An empty string if not connected. Never <code>null</code>.
 */
public String getHostName() {
    if (git != null) {
        Config storedConfig = git.getRepository().getConfig();
        // TODO How we should react when there are multiple remote repositories???
        String url = storedConfig.getString("remote", "origin", "url");
        if (url == null) {
          Set<String> remoteNames = git.getRepository().getRemoteNames();
          url = storedConfig.getString("remote", remoteNames.iterator().next(), "url");
        }
        try {
            URL u = new URL(url);
            url = u.getHost();
            return url;
        } catch (MalformedURLException e) {
            return "";
        }
    }
    return "";

}
项目:incubator-netbeans    文件:Utils.java   
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);
    }
}
项目:incubator-netbeans    文件:SetUpstreamBranchTest.java   
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));
}
项目:pdi-git-plugin    文件:UIGit.java   
@Override
public String getAuthorName( String commitId ) {
  if ( commitId.equals( IVCS.WORKINGTREE ) ) {
    Config config = git.getRepository().getConfig();
    return config.get( UserConfig.KEY ).getAuthorName()
        + " <" + config.get( UserConfig.KEY ).getAuthorEmail() + ">";
  } else {
    RevCommit commit = resolve( commitId );
    PersonIdent author = commit.getAuthorIdent();
    final StringBuilder r = new StringBuilder();
    r.append( author.getName() );
    r.append( " <" ); //$NON-NLS-1$
    r.append( author.getEmailAddress() );
    r.append( ">" ); //$NON-NLS-1$
    return r.toString();
  }
}
项目:gerrit    文件:AbstractElasticIndex.java   
AbstractElasticIndex(
    @GerritServerConfig Config cfg,
    SitePaths sitePaths,
    Schema<V> schema,
    JestClientBuilder clientBuilder,
    String indexName) {
  this.sitePaths = sitePaths;
  this.schema = schema;
  this.gson = new GsonBuilder().setFieldNamingPolicy(LOWER_CASE_WITH_UNDERSCORES).create();
  this.queryBuilder = new ElasticQueryBuilder();
  this.indexName =
      String.format(
          "%s%s%04d",
          Strings.nullToEmpty(cfg.getString("elasticsearch", null, "prefix")),
          indexName,
          schema.getVersion());
  this.client = clientBuilder.build();
}
项目:gerrit    文件:AccountConfig.java   
@Override
protected void onLoad() throws IOException, ConfigInvalidException {
  if (revision != null) {
    rw.reset();
    rw.markStart(revision);
    rw.sort(RevSort.REVERSE);
    registeredOn = new Timestamp(rw.next().getCommitTime() * 1000L);

    Config cfg = readConfig(ACCOUNT_CONFIG);

    account = parse(cfg);
    account.setMetaId(revision.name());
  }

  isLoaded = true;
}
项目:rtc2gitcli    文件:GitMigrator.java   
private void fillConfigFromProperties(Config config) {
    for (Entry<Object, Object> entry : properties.entrySet()) {
        if (entry.getKey() instanceof String && (((String) entry.getKey()).startsWith(GIT_CONFIG_PREFIX))) {

            String key = ((String) entry.getKey()).substring(GIT_CONFIG_PREFIX.length());
            int dot = key.indexOf('.');
            int dot1 = key.lastIndexOf('.');
            // so far supporting section/key entries, no subsections
            if (dot < 1 || dot == key.length() - 1 || dot1 != dot) {
                // invalid config key entry
                continue;
            }
            String section = key.substring(0, dot);
            String name = key.substring(dot + 1);
            config.setString(section, null, name, entry.getValue().toString());
        }

    }
}
项目:gerrit    文件:SignedPushModule.java   
@Inject
Initializer(
    @GerritServerConfig Config cfg,
    @EnableSignedPush boolean enableSignedPush,
    SignedPushPreReceiveHook hook,
    ProjectCache projectCache) {
  this.hook = hook;
  this.projectCache = projectCache;

  if (enableSignedPush) {
    String seed = cfg.getString("receive", null, "certNonceSeed");
    if (Strings.isNullOrEmpty(seed)) {
      seed = randomString(64);
    }
    signedPushConfig = new SignedPushConfig();
    signedPushConfig.setCertNonceSeed(seed);
    signedPushConfig.setCertNonceSlopLimit(
        cfg.getInt("receive", null, "certNonceSlop", 5 * 60));
  } else {
    signedPushConfig = null;
  }
}
项目:gerrit    文件:IndexModule.java   
@Provides
@Singleton
@IndexExecutor(INTERACTIVE)
ListeningExecutorService getInteractiveIndexExecutor(
    @GerritServerConfig Config config, WorkQueue workQueue) {
  if (interactiveExecutor != null) {
    return interactiveExecutor;
  }
  int threads = this.threads;
  if (threads <= 0) {
    threads = config.getInt("index", null, "threads", 0);
  }
  if (threads <= 0) {
    threads = Runtime.getRuntime().availableProcessors() / 2 + 1;
  }
  return MoreExecutors.listeningDecorator(workQueue.createQueue(threads, "Index-Interactive"));
}
项目:gerrit    文件:InitDatabase.java   
private void initNoteDb() {
  ui.header("NoteDb Database");
  ui.message(
      "Use NoteDb for change metadata?\n"
          + "  See documentation:\n"
          + "  https://gerrit-review.googlesource.com/Documentation/note-db.html\n");
  if (!ui.yesno(true, "Enable")) {
    return;
  }

  Config defaultConfig = new Config();
  NotesMigrationState.FINAL.setConfigValues(defaultConfig);
  for (String name : defaultConfig.getNames(SECTION_NOTE_DB, CHANGES.key())) {
    noteDbChanges.set(name, defaultConfig.getString(SECTION_NOTE_DB, CHANGES.key(), name));
  }
}
项目:gerrit    文件:AdministrateServerGroupsProvider.java   
@Inject
public AdministrateServerGroupsProvider(
    GroupBackend groupBackend,
    @GerritServerConfig Config config,
    ThreadLocalRequestContext threadContext,
    ServerRequestContext serverCtx) {
  RequestContext ctx = threadContext.setContext(serverCtx);
  try {
    ImmutableSet.Builder<GroupReference> builder = ImmutableSet.builder();
    for (String value : config.getStringList("capability", null, "administrateServer")) {
      PermissionRule rule = PermissionRule.fromString(value, false);
      String name = rule.getGroup().getName();
      GroupReference g = GroupBackends.findBestSuggestion(groupBackend, name);
      if (g != null) {
        builder.add(g);
      } else {
        Logger log = LoggerFactory.getLogger(getClass());
        log.warn("Group \"{}\" not available, skipping.", name);
      }
    }
    groups = builder.build();
  } finally {
    threadContext.setContext(ctx);
  }
}
项目:gerrit    文件:JettyServer.java   
static URI[] listenURLs(Config cfg) {
  String[] urls = cfg.getStringList("httpd", null, "listenurl");
  if (urls.length == 0) {
    urls = new String[] {"http://*:8080/"};
  }

  final URI[] r = new URI[urls.length];
  for (int i = 0; i < r.length; i++) {
    final String s = urls[i];
    try {
      r[i] = new URI(s);
    } catch (URISyntaxException e) {
      throw new IllegalArgumentException("Invalid httpd.listenurl " + s, e);
    }
  }
  return r;
}
项目:gerrit    文件:ChangeKindCacheImpl.java   
@Override
public ChangeKind getChangeKind(
    Project.NameKey project,
    @Nullable RevWalk rw,
    @Nullable Config repoConfig,
    ObjectId prior,
    ObjectId next) {
  try {
    Key key = new Key(prior, next, useRecursiveMerge);
    return new Loader(key, repoManager, project, rw, repoConfig).call();
  } catch (IOException e) {
    log.warn(
        "Cannot check trivial rebase of new patch set " + next.name() + " in " + project, e);
    return ChangeKind.REWORK;
  }
}
项目:gerrit    文件:GerritIndexWriterConfig.java   
GerritIndexWriterConfig(Config cfg, String name) {
  analyzer =
      new CustomMappingAnalyzer(
          new StandardAnalyzer(CharArraySet.EMPTY_SET), CUSTOM_CHAR_MAPPING);
  luceneConfig =
      new IndexWriterConfig(analyzer)
          .setOpenMode(OpenMode.CREATE_OR_APPEND)
          .setCommitOnClose(true);
  double m = 1 << 20;
  luceneConfig.setRAMBufferSizeMB(
      cfg.getLong(
              "index",
              name,
              "ramBufferSize",
              (long) (IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB * m))
          / m);
  luceneConfig.setMaxBufferedDocs(
      cfg.getInt("index", name, "maxBufferedDocs", IndexWriterConfig.DEFAULT_MAX_BUFFERED_DOCS));
  try {
    commitWithinMs =
        ConfigUtil.getTimeUnit(
            cfg, "index", name, "commitWithin", MILLISECONDS.convert(5, MINUTES), MILLISECONDS);
  } catch (IllegalArgumentException e) {
    commitWithinMs = cfg.getLong("index", name, "commitWithin", 0);
  }
}
项目:gerrit    文件:GroupsIT.java   
@Test
public void pushGroupsAccessSectionChangeToAllUsersFails() throws Exception {
  TestRepository<InMemoryRepository> repo = cloneProject(allUsers, RefNames.REFS_CONFIG);

  String config =
      gApi.projects()
          .name(allUsers.get())
          .branch(RefNames.REFS_CONFIG)
          .file(ProjectConfig.PROJECT_CONFIG)
          .asString();

  Config cfg = new Config();
  cfg.fromText(config);
  cfg.setString("access", RefNames.REFS_GROUPS + "foo", "push", "group Registered Users");
  config = cfg.toText();

  PushOneCommit.Result r =
      pushFactory
          .create(db, admin.getIdent(), repo, "Subject", ProjectConfig.PROJECT_CONFIG, config)
          .to(RefNames.REFS_CONFIG);
  r.assertErrorStatus("invalid project configuration");
  r.assertMessage("permissions on refs/groups/ are managed by gerrit and cannot be modified");
}
项目:gerrit    文件:RobotCommentUpdate.java   
@AssistedInject
private RobotCommentUpdate(
    @GerritServerConfig Config cfg,
    @GerritPersonIdent PersonIdent serverIdent,
    @AnonymousCowardName String anonymousCowardName,
    NotesMigration migration,
    ChangeNoteUtil noteUtil,
    @Assisted ChangeNotes notes,
    @Assisted("effective") Account.Id accountId,
    @Assisted("real") Account.Id realAccountId,
    @Assisted PersonIdent authorIdent,
    @Assisted Date when) {
  super(
      cfg,
      migration,
      noteUtil,
      serverIdent,
      anonymousCowardName,
      notes,
      null,
      accountId,
      realAccountId,
      authorIdent,
      when);
}
项目:gerrit    文件:ScheduleConfig.java   
@VisibleForTesting
ScheduleConfig(
    Config rc,
    String section,
    String subsection,
    String keyInterval,
    String keyStartTime,
    ZonedDateTime now) {
  this.rc = rc;
  this.section = section;
  this.subsection = subsection;
  this.keyInterval = keyInterval;
  this.keyStartTime = keyStartTime;
  this.interval = interval(rc, section, subsection, keyInterval);
  if (interval > 0) {
    this.initialDelay = initialDelay(rc, section, subsection, keyStartTime, now, interval);
  } else {
    this.initialDelay = interval;
  }
}
项目:gerrit    文件:ErrorLogFile.java   
public static LifecycleListener start(Path sitePath, Config config) throws IOException {
  Path logdir =
      FileUtil.mkdirsOrDie(new SitePaths(sitePath).logs_dir, "Cannot create log directory");
  if (SystemLog.shouldConfigure()) {
    initLogSystem(logdir, config);
  }

  return new LifecycleListener() {
    @Override
    public void start() {}

    @Override
    public void stop() {
      LogManager.shutdown();
    }
  };
}
项目:gerrit    文件:GerritServer.java   
private GerritServer(
    Description desc,
    @Nullable Path sitePath,
    Injector testInjector,
    Daemon daemon,
    @Nullable ExecutorService daemonService) {
  this.desc = checkNotNull(desc);
  this.sitePath = sitePath;
  this.testInjector = checkNotNull(testInjector);
  this.daemon = checkNotNull(daemon);
  this.daemonService = daemonService;

  Config cfg = testInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
  url = cfg.getString("gerrit", null, "canonicalWebUrl");
  URI uri = URI.create(url);

  sshdAddress = SocketUtil.resolve(cfg.getString("sshd", null, "listenAddress"), 0);
  httpAddress = new InetSocketAddress(uri.getHost(), uri.getPort());
}
项目:gerrit    文件:ProjectConfig.java   
private void loadPluginSections(Config rc) {
  pluginConfigs = new HashMap<>();
  for (String plugin : rc.getSubsections(PLUGIN)) {
    Config pluginConfig = new Config();
    pluginConfigs.put(plugin, pluginConfig);
    for (String name : rc.getNames(PLUGIN, plugin)) {
      String value = rc.getString(PLUGIN, plugin, name);
      String groupName = GroupReference.extractGroupName(value);
      if (groupName != null) {
        GroupReference ref = groupsByName.get(groupName);
        if (ref == null) {
          error(
              new ValidationError(
                  PROJECT_CONFIG, "group \"" + groupName + "\" not in " + GroupList.FILE_NAME));
        }
        rc.setString(PLUGIN, plugin, name, value);
      }
      pluginConfig.setStringList(
          PLUGIN, plugin, name, Arrays.asList(rc.getStringList(PLUGIN, plugin, name)));
    }
  }
}
项目:gerrit    文件:ConfigAnnotationParser.java   
private static void parseAnnotation(Config cfg, GerritConfig c) {
  ArrayList<String> l = Lists.newArrayList(splitter.split(c.name()));
  if (l.size() == 2) {
    if (!Strings.isNullOrEmpty(c.value())) {
      cfg.setString(l.get(0), null, l.get(1), c.value());
    } else {
      String[] values = c.values();
      cfg.setStringList(l.get(0), null, l.get(1), Arrays.asList(values));
    }
  } else if (l.size() == 3) {
    if (!Strings.isNullOrEmpty(c.value())) {
      cfg.setString(l.get(0), l.get(1), l.get(2), c.value());
    } else {
      cfg.setStringList(l.get(0), l.get(1), l.get(2), Arrays.asList(c.values()));
    }
  } else {
    throw new IllegalArgumentException(
        "GerritConfig.name must be of the format section.subsection.name or section.name");
  }
}
项目:gerrit    文件:DatabasePubKeyAuth.java   
@Inject
DatabasePubKeyAuth(
    SshKeyCacheImpl skc,
    SshLog l,
    IdentifiedUser.GenericFactory uf,
    PeerDaemonUser.Factory pf,
    SitePaths site,
    KeyPairProvider hostKeyProvider,
    @GerritServerConfig Config cfg,
    SshScope s) {
  sshKeyCache = skc;
  sshLog = l;
  userFactory = uf;
  peerFactory = pf;
  config = cfg;
  sshScope = s;
  myHostKeys = myHostKeys(hostKeyProvider);
  peerKeyCache = new PeerKeyCache(site.peer_keys);
}
项目:gerrit    文件:GitUploadPackGroupsProvider.java   
@Inject
public GitUploadPackGroupsProvider(
    GroupBackend gb,
    @GerritServerConfig Config config,
    ThreadLocalRequestContext threadContext,
    ServerRequestContext serverCtx) {
  super(
      gb,
      threadContext,
      serverCtx,
      ImmutableList.copyOf(config.getStringList("upload", null, "allowGroup")));

  // If no group was set, default to "registered users" and "anonymous"
  //
  if (groupIds.isEmpty()) {
    groupIds =
        ImmutableSet.of(SystemGroupBackend.REGISTERED_USERS, SystemGroupBackend.ANONYMOUS_USERS);
  }
}
项目:gerrit    文件:GitwebConfig.java   
@Inject
GitwebConfig(GitwebCgiConfig cgiConfig, @GerritServerConfig Config cfg) {
  if (isDisabled(cfg)) {
    type = null;
    url = null;
  } else {
    String cfgUrl = cfg.getString("gitweb", null, "url");
    type = typeFromConfig(cfg);
    if (type == null) {
      url = null;
    } else if (cgiConfig.getGitwebCgi() == null) {
      // Use an externally managed gitweb instance, and not an internal one.
      url = cfgUrl;
    } else {
      url = firstNonNull(cfgUrl, "gitweb");
    }
  }
}
项目:gerrit    文件:RetryHelper.java   
@Inject
RetryHelper(
    @GerritServerConfig Config cfg,
    Metrics metrics,
    NotesMigration migration,
    ReviewDbBatchUpdate.AssistedFactory reviewDbBatchUpdateFactory,
    NoteDbBatchUpdate.AssistedFactory noteDbBatchUpdateFactory) {
  this.metrics = metrics;
  this.migration = migration;
  this.updateFactory =
      new BatchUpdate.Factory(migration, reviewDbBatchUpdateFactory, noteDbBatchUpdateFactory);
  this.defaultTimeout =
      Duration.ofMillis(
          cfg.getTimeUnit("noteDb", null, "retryTimeout", SECONDS.toMillis(20), MILLISECONDS));
  this.waitStrategy =
      WaitStrategies.join(
          WaitStrategies.exponentialWait(
              cfg.getTimeUnit("noteDb", null, "retryMaxWait", SECONDS.toMillis(5), MILLISECONDS),
              MILLISECONDS),
          WaitStrategies.randomWait(50, MILLISECONDS));
}
项目:gerrit    文件:AbstractChangeUpdate.java   
protected AbstractChangeUpdate(
    Config cfg,
    NotesMigration migration,
    ChangeNotes notes,
    CurrentUser user,
    PersonIdent serverIdent,
    String anonymousCowardName,
    ChangeNoteUtil noteUtil,
    Date when) {
  this.migration = migration;
  this.noteUtil = noteUtil;
  this.serverIdent = new PersonIdent(serverIdent, when);
  this.anonymousCowardName = anonymousCowardName;
  this.notes = notes;
  this.change = notes.getChange();
  this.accountId = accountId(user);
  Account.Id realAccountId = accountId(user.getRealUser());
  this.realAccountId = realAccountId != null ? realAccountId : accountId;
  this.authorIdent = ident(noteUtil, serverIdent, anonymousCowardName, user, when);
  this.when = when;
  this.readOnlySkewMs = NoteDbChangeState.getReadOnlySkew(cfg);
}
项目:gerrit    文件:SetPreferences.java   
public static void storeUrlAliases(
    VersionedAccountPreferences prefs, Map<String, String> urlAliases) {
  if (urlAliases != null) {
    Config cfg = prefs.getConfig();
    for (String subsection : cfg.getSubsections(URL_ALIAS)) {
      cfg.unsetSection(URL_ALIAS, subsection);
    }

    int i = 1;
    for (Entry<String, String> e : urlAliases.entrySet()) {
      cfg.setString(URL_ALIAS, URL_ALIAS + i, KEY_MATCH, e.getKey());
      cfg.setString(URL_ALIAS, URL_ALIAS + i, KEY_TOKEN, e.getValue());
      i++;
    }
  }
}
项目:gerrit    文件:ChangeKindCacheImpl.java   
private Loader(
    Key key,
    GitRepositoryManager repoManager,
    Project.NameKey projectName,
    @Nullable RevWalk rw,
    @Nullable Config repoConfig) {
  checkArgument(
      (rw == null && repoConfig == null) || (rw != null && repoConfig != null),
      "must either provide both revwalk/config, or neither; got %s/%s",
      rw,
      repoConfig);
  this.key = key;
  this.repoManager = repoManager;
  this.projectName = projectName;
  this.alreadyOpenRw = rw;
  this.repoConfig = repoConfig;
}
项目:n4js    文件:RepoRelativePath.java   
/**
 * Tries to obtain repository name from the provided directory by reading git config in
 * {@code currendDir/.git/config}
 *
 * @return string with repo name or {@code null}
 */
private static String getRepoName(File currentDir) {
    File gitFolder = new File(currentDir, ".git");
    if (!gitFolder.isDirectory()) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("No '.git' folder at " + currentDir.getAbsolutePath());
        return null;
    }

    File config = new File(gitFolder, "config");
    if (!config.isFile()) {
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("No 'config' file at " + gitFolder.getAbsolutePath());
        return null;
    }
    try {
        String configStr = Files.readFileIntoString(config.getAbsolutePath());
        Config cfg = new Config();

        cfg.fromText(configStr);
        String originURL = cfg.getString("remote", "origin", "url");
        if (originURL != null && !originURL.isEmpty()) {
            int lastSlash = originURL.lastIndexOf('/');
            String repoName = null;
            if (lastSlash >= 0) {
                repoName = originURL.substring(lastSlash + 1);
            } else {
                repoName = originURL;
            }
            if (repoName.endsWith(".git")) {
                repoName = repoName.substring(0, repoName.length() - 4);
            }
            return repoName;
        }
    } catch (ConfigInvalidException e) {
        LOGGER.warn("Cannot read git config at " + config.getAbsolutePath(), e);
    }

    return null;
}
项目:incubator-netbeans    文件:ListBranchCommand.java   
@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);
    }
}
项目:incubator-netbeans    文件:ListBranchCommand.java   
private Map<String, GitBranch> getRefs (Collection<Ref> allRefs, String prefix, boolean isRemote, String activeBranch, Config config) {
    Map<String, GitBranch> branches = new LinkedHashMap<String, GitBranch>();
    for (final Ref ref : RefComparator.sort(allRefs)) {
        String refName = ref.getLeaf().getName();
        if (refName.startsWith(prefix)) {
            String name = refName.substring(refName.indexOf('/', 5) + 1);
            branches.put(name, getClassFactory().createBranch(name, isRemote, refName.equals(activeBranch), ref.getLeaf().getObjectId()));
        }
    }
    return branches;
}
项目:mesfavoris    文件:RepositoryCommitBookmarkLocationProvider.java   
private Set<String> getRemotesUrls(Repository repository) {
    Set<String> remoteUrls = new HashSet<String>();
    Config storedConfig = repository.getConfig();
    Set<String> remotes = storedConfig.getSubsections("remote");
    for (String remoteName : remotes) {
        String url = storedConfig.getString("remote", remoteName, "url");
        remoteUrls.add(url);
    }
    return remoteUrls;
}
项目:mesfavoris    文件:CommitBookmarkPropertiesProvider.java   
private Set<String> getRemotesUrls(Repository repository) {
    Set<String> remoteUrls = new HashSet<String>();
    Config storedConfig = repository.getConfig();
    Set<String> remotes = storedConfig.getSubsections("remote");
    for (String remoteName : remotes) {
        String url = storedConfig.getString("remote", remoteName, "url");
        remoteUrls.add(url);
    }
    return remoteUrls;
}
项目:mesfavoris    文件:GitTestHelper.java   
private static Set<String> getRemotesUrls(Repository repository) {
    Set<String> remoteUrls = new HashSet<String>();
    Config storedConfig = repository.getConfig();
    Set<String> remotes = storedConfig.getSubsections("remote");
    for (String remoteName : remotes) {
        String url = storedConfig.getString("remote", remoteName, "url");
        remoteUrls.add(url);
    }
    return remoteUrls;
}
项目:gerrit    文件:ApprovalsUtil.java   
public Iterable<PatchSetApproval> byPatchSet(
    ReviewDb db,
    ChangeNotes notes,
    CurrentUser user,
    PatchSet.Id psId,
    @Nullable RevWalk rw,
    @Nullable Config repoConfig)
    throws OrmException {
  if (!migration.readChanges()) {
    return sortApprovals(db.patchSetApprovals().byPatchSet(psId));
  }
  return copier.getForPatchSet(db, notes, user, psId, rw, repoConfig);
}
项目:gerrit    文件:ApprovalCopier.java   
/**
 * Apply approval copy settings from prior PatchSets to a new PatchSet.
 *
 * @param db review database.
 * @param notes change notes for user uploading PatchSet
 * @param user user uploading PatchSet
 * @param ps new PatchSet
 * @param rw open walk that can read the patch set commit; null to open the repo on demand.
 * @param repoConfig repo config used for change kind detection; null to read from repo on demand.
 * @param dontCopy PatchSetApprovals indicating which (account, label) pairs should not be copied
 * @throws OrmException
 */
public void copyInReviewDb(
    ReviewDb db,
    ChangeNotes notes,
    CurrentUser user,
    PatchSet ps,
    @Nullable RevWalk rw,
    @Nullable Config repoConfig,
    Iterable<PatchSetApproval> dontCopy)
    throws OrmException {
  if (PrimaryStorage.of(notes.getChange()) == PrimaryStorage.REVIEW_DB) {
    db.patchSetApprovals().insert(getForPatchSet(db, notes, user, ps, rw, repoConfig, dontCopy));
  }
}
项目:gerrit    文件:CommentSender.java   
@Inject
public CommentSender(
    EmailArguments ea,
    CommentsUtil commentsUtil,
    @GerritServerConfig Config cfg,
    @Assisted Project.NameKey project,
    @Assisted Change.Id id)
    throws OrmException {
  super(ea, "comment", newChangeData(ea, project, id));
  this.commentsUtil = commentsUtil;
  this.incomingEmailEnabled =
      cfg.getEnum("receiveemail", null, "protocol", Protocol.NONE).ordinal()
          > Protocol.NONE.ordinal();
  this.replyToAddress = cfg.getString("sendemail", null, "replyToAddress");
}
项目:gerrit    文件:GetServerInfo.java   
private Map<String, String> getUrlAliasesInfo(Config cfg) {
  Map<String, String> urlAliases = new HashMap<>();
  for (String subsection : cfg.getSubsections(URL_ALIAS)) {
    urlAliases.put(
        cfg.getString(URL_ALIAS, subsection, KEY_MATCH),
        cfg.getString(URL_ALIAS, subsection, KEY_TOKEN));
  }
  return urlAliases;
}
项目:plugins_download-commands    文件:CherryPickCommand.java   
@Inject
CherryPickCommand(
    @GerritServerConfig Config cfg,
    DownloadConfig downloadConfig,
    GitRepositoryManager repoManager) {
  super(cfg, downloadConfig, CHERRY_PICK, repoManager);
}
项目:gerrit    文件:SetPreferences.java   
public static void storeMyChangeTableColumns(
    VersionedAccountPreferences prefs, List<String> changeTable) {
  Config cfg = prefs.getConfig();
  if (changeTable != null) {
    unsetSection(cfg, UserConfigSections.CHANGE_TABLE);
    cfg.setStringList(UserConfigSections.CHANGE_TABLE, null, CHANGE_TABLE_COLUMN, changeTable);
  }
}