當前位置: 首頁>>代碼示例>>Java>>正文


Java StoredConfig.getString方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.lib.StoredConfig.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java StoredConfig.getString方法的具體用法?Java StoredConfig.getString怎麽用?Java StoredConfig.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.lib.StoredConfig的用法示例。


在下文中一共展示了StoredConfig.getString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isUserSetup

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的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: doPull

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
protected void doPull(File gitFolder, CredentialsProvider cp, String branch, PersonIdent personIdent, UserDetails userDetails) {
    try {
        FileRepositoryBuilder builder = new FileRepositoryBuilder();
        Repository repository = builder.setGitDir(gitFolder)
                .readEnvironment() // scan environment GIT_* variables
                .findGitDir() // scan up the file system tree
                .build();

        Git git = new Git(repository);

        File projectFolder = repository.getDirectory();

        StoredConfig config = repository.getConfig();
        String url = config.getString("remote", userDetails.getRemote(), "url");
        if (Strings.isNullOrBlank(url)) {
            LOG.warn("No remote repository url for " + branch + " defined for the git repository at " + projectFolder.getCanonicalPath() + " so cannot pull");
            //return;
        }
        String mergeUrl = config.getString("branch", branch, "merge");
        if (Strings.isNullOrBlank(mergeUrl)) {
            LOG.warn("No merge spec for branch." + branch + ".merge in the git repository at " + projectFolder.getCanonicalPath() + " so not doing a pull");
            //return;
        }

        LOG.debug("Performing a pull in git repository " + projectFolder.getCanonicalPath() + " on remote URL: " + url);
        PullCommand pull = git.pull();
        GitHelpers.configureCommand(pull, userDetails);
        pull.setRebase(true).call();
    } catch (Throwable e) {
        LOG.error("Failed to pull from the remote git repo with credentials " + cp + " due: " + e.getMessage() + ". This exception is ignored.", e);
    }
}
 
開發者ID:fabric8io,項目名稱:fabric8-devops,代碼行數:33,代碼來源:GitBuildConfigProcessor.java

示例3: execute

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
public List<RefSpec> execute() throws IOException, URISyntaxException {
    final List<RefSpec> specs = new ArrayList<>();
    if (refSpecs == null || refSpecs.isEmpty()) {
        specs.add(new RefSpec("+refs/heads/*:refs/remotes/" + remote.getK1() + "/*"));
        specs.add(new RefSpec("+refs/tags/*:refs/tags/*"));
        specs.add(new RefSpec("+refs/notes/*:refs/notes/*"));
    } else {
        specs.addAll(refSpecs);
    }

    final StoredConfig config = git.getRepository().getConfig();
    final String url = config.getString("remote",
                                        remote.getK1(),
                                        "url");
    if (url == null) {
        final RemoteConfig remoteConfig = new RemoteConfig(git.getRepository().getConfig(),
                                                           remote.getK1());
        remoteConfig.addURI(new URIish(remote.getK2()));
        specs.forEach(remoteConfig::addFetchRefSpec);
        remoteConfig.update(git.getRepository().getConfig());
        git.getRepository().getConfig().save();
    }
    return specs;
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:25,代碼來源:UpdateRemoteConfig.java

示例4: loadDescriptionText

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
private String loadDescriptionText(Repository repo) throws IOException {
  String desc = null;
  StoredConfig config = repo.getConfig();
  IOException configError = null;
  try {
    config.load();
    desc = config.getString("gitweb", null, "description");
  } catch (ConfigInvalidException e) {
    configError = new IOException(e);
  }
  if (desc == null) {
    File descFile = new File(repo.getDirectory(), "description");
    if (descFile.exists()) {
      desc = new String(IO.readFully(descFile));
      if (DEFAULT_DESCRIPTION.equals(CharMatcher.WHITESPACE.trimFrom(desc))) {
        desc = null;
      }
    } else if (configError != null) {
      throw configError;
    }
  }
  return desc;
}
 
開發者ID:afrojer,項目名稱:gitiles,代碼行數:24,代碼來源:DefaultAccess.java

示例5: getRemoteOriginURL

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
public String getRemoteOriginURL() {
    try {
        StoredConfig config = getStoredConfig();
        String origin = config.getString("remote", "origin", "url");
        if (origin != null && !origin.isEmpty())
            return origin;
        Set<String> remoteNames = config.getSubsections("remote");
        if (remoteNames.size() == 0)
            return "";
        String url = config.getString("remote", remoteNames.iterator()
                .next(), "url");
        return url;
    } catch (StopTaskException e) {
    }
    return "";
}
 
開發者ID:sheimi,項目名稱:SGit,代碼行數:17,代碼來源:Repo.java

示例6: setupRebaseFlag

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的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

示例7: setupRebaseFlag

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的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

示例8: loadRegisteredRepositories

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
private void loadRegisteredRepositories() {
    repositoryMap = new TreeMap<String, Repository>();
    final List<String> repositoryFolders = Activator.getDefault().getRepositoryUtil().getConfiguredRepositories();

    for (final String repositoryFolder : repositoryFolders) {
        final File folder = new File(repositoryFolder);
        if (!folder.exists() || !folder.isDirectory()) {
            continue;
        }

        if (!folder.getName().equals(Constants.DOT_GIT) || !FileKey.isGitRepository(folder, FS.DETECTED)) {
            continue;
        }

        final RepositoryBuilder rb = new RepositoryBuilder().setGitDir(folder).setMustExist(true);

        try {
            final Repository repo = rb.build();
            final StoredConfig repositoryConfig = repo.getConfig();
            final Set<String> remotes = repositoryConfig.getSubsections(REMOTES_SECTION_NAME);

            for (final String remoteName : remotes) {
                final String remoteURL =
                    repositoryConfig.getString(REMOTES_SECTION_NAME, remoteName, URL_VALUE_NAME);
                repositoryMap.put(remoteURL, repo);
            }
        } catch (final Exception e) {
            log.error("Error loading local Git repository " + repositoryFolder, e); //$NON-NLS-1$
            continue;
        }
    }
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:33,代碼來源:TeamExplorerGitRepositoriesSection.java

示例9: getUrl

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
private String getUrl(RepositoryMapping mapping, String branch) {
	StoredConfig config = mapping.getRepository().getConfig();
	String remote = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION, branch,
			ConfigConstants.CONFIG_KEY_REMOTE);
	String url = config.getString(ConfigConstants.CONFIG_REMOTE_SECTION, remote, ConfigConstants.CONFIG_KEY_URL);
	return url;
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:8,代碼來源:GitProjectPropertiesProvider.java

示例10: getRepositoryName

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
/**
 * This method returns the current repository name.This method is used in setting the file name for file export options.
 * @return
 */
@Override
public String getRepositoryName(){
        StoredConfig c = repo.getConfig();
    try{
        String url = c.getString("remote", "origin","url");
        if(url!= null && !url.isEmpty()){
            return url.substring(url.lastIndexOf('/') +1);
        }
    }catch(Exception e){
        e.printStackTrace();

    }
    return ".git";
}
 
開發者ID:AMOSTeam3,項目名稱:amos-ss15-proj3,代碼行數:19,代碼來源:GitVcsClient.java

示例11: 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);
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:36,代碼來源:JGitConnection.java

示例12: handleInvalidConfigurationError

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
/**
 * Handles the Invalid configuration issues
 *
 * @param gitRepoCtx RepositoryContext instance of the tenant
 */
private void handleInvalidConfigurationError(RepositoryContext gitRepoCtx) {

    StoredConfig storedConfig = gitRepoCtx.getLocalRepo().getConfig();
    boolean modifiedConfig = false;
    if (storedConfig != null) {

        if (storedConfig.getString("branch", "master", "remote") == null ||
                storedConfig.getString("branch", "master", "remote").isEmpty()) {

            storedConfig.setString("branch", "master", "remote", "origin");
            modifiedConfig = true;
        }

        if (storedConfig.getString("branch", "master", "merge") == null ||
                storedConfig.getString("branch", "master", "merge").isEmpty()) {

            storedConfig.setString("branch", "master", "merge", "refs/heads/master");
            modifiedConfig = true;
        }

        if (modifiedConfig) {
            try {
                storedConfig.save();
                // storedConfig.load();

            } catch (IOException e) {
                String message = "Error saving git configuration file in local repo at " + gitRepoCtx.getGitLocalRepoPath();
                System.out.println(message);
                log.error(message, e);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:stratos,代碼行數:39,代碼來源:GitBasedArtifactRepository.java

示例13: getConfig

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
/**
 * Returns the gitblit string value for the specified key. If key is not
 * set, returns defaultValue.
 * 
 * @param config
 * @param field
 * @param defaultValue
 * @return field value or defaultValue
 */
private int getConfig(StoredConfig config, String field, int defaultValue) {
	String value = config.getString(Constants.CONFIG_GITBLIT, null, field);
	if (StringUtils.isEmpty(value)) {
		return defaultValue;
	}
	try {
		return Integer.parseInt(value);
	} catch (Exception e) {
	}
	return defaultValue;
}
 
開發者ID:warpfork,項目名稱:gitblit,代碼行數:21,代碼來源:GitBlit.java

示例14: commit

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
public static void commit(Repo repo, boolean stageAll, boolean isAmend,
        String msg, String authorName, String authorEmail) throws Exception, NoHeadException, NoMessageException,
        UnmergedPathsException, ConcurrentRefUpdateException,
        WrongRepositoryStateException, GitAPIException, StopTaskException {
    Context context = SGitApplication.getContext();
    StoredConfig config = repo.getGit().getRepository().getConfig();
    String committerEmail = config.getString("user", null, "email");
    String committerName = config.getString("user", null, "name");

    if (committerName == null || committerName.equals("")) {
        committerName = Profile.getUsername(context);
    }
    if (committerEmail == null || committerEmail.equals("")) {
        committerEmail = Profile.getEmail(context);
    }
    if (committerName.isEmpty() || committerEmail.isEmpty()) {
        throw new Exception("Please set your name and email");
    }
    if (msg.isEmpty()) {
        throw new Exception("Please include a commit message");
    }
    CommitCommand cc = repo.getGit().commit()
            .setCommitter(committerName, committerEmail).setAll(stageAll)
            .setAmend(isAmend).setMessage(msg);
    if (authorName != null && authorEmail != null) {
        cc.setAuthor(authorName, authorEmail);
    }
    cc.call();
    repo.updateLatestCommitInfo();
}
 
開發者ID:sheimi,項目名稱:SGit,代碼行數:31,代碼來源:CommitChangesTask.java

示例15: onCreateDialog

import org.eclipse.jgit.lib.StoredConfig; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    mActivity = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    LayoutInflater inflater = mActivity.getLayoutInflater();
    View layout = inflater.inflate(R.layout.dialog_repo_config, null);
    builder.setView(layout);

    mGitName = (EditText) layout.findViewById(R.id.gitName);
    mGitEmail = (EditText) layout.findViewById(R.id.gitEmail);

    StoredConfig config;
    String stored_name = "";
    String stored_email = "";

    try {
        config = ((Repo)getArguments().getSerializable(REPO_ARG_KEY)).getGit().getRepository().getConfig();
        stored_name = config.getString("user", null, "name");
        stored_email = config.getString("user", null, "email");
    } catch (StopTaskException e) {
    }
    if (stored_name == null)
        stored_name = "";
    if (stored_email == null)
        stored_email = "";
    mGitName.setText(stored_name);
    mGitEmail.setText(stored_email);

    // set button listener
    builder.setTitle(R.string.title_config_repo);
    builder.setNegativeButton(R.string.label_cancel,
            new DummyDialogListener());
    builder.setPositiveButton(R.string.label_save, this);

    return builder.create();
}
 
開發者ID:sheimi,項目名稱:SGit,代碼行數:38,代碼來源:ConfigRepoDialog.java


注:本文中的org.eclipse.jgit.lib.StoredConfig.getString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。