Package org.eclipse.jgit.lib

Examples of org.eclipse.jgit.lib.StoredConfig


          doConfigure = baseBranch.startsWith(Constants.R_REMOTES);
        }
      }

      if (doConfigure) {
        StoredConfig config = repo.getConfig();
        String[] tokens = baseBranch.split("/", 4);
        boolean isRemote = tokens[1].equals("remotes");
        if (isRemote) {
          // refs/remotes/<remote name>/<branch>
          String remoteName = tokens[2];
          String branchName = tokens[3];
          config
              .setString(ConfigConstants.CONFIG_BRANCH_SECTION,
                  name, ConfigConstants.CONFIG_KEY_REMOTE,
                  remoteName);
          config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
              name, ConfigConstants.CONFIG_KEY_MERGE,
              Constants.R_HEADS + branchName);
        } else {
          // set "." as remote
          config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
              name, ConfigConstants.CONFIG_KEY_REMOTE, ".");
          config.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
              name, ConfigConstants.CONFIG_KEY_MERGE, baseBranch);
        }
        config.save();
      }
      return result;
    } catch (IOException ioe) {
      throw new JGitInternalException(ioe.getMessage(), ioe);
    } finally {
View Full Code Here


      if (ok) {
        if (fullNewName.startsWith(Constants.R_HEADS)) {
          // move the upstream configuration over to the new branch
          String shortOldName = fullOldName
              .substring(Constants.R_HEADS.length());
          final StoredConfig repoConfig = repo.getConfig();
          String oldRemote = repoConfig.getString(
              ConfigConstants.CONFIG_BRANCH_SECTION,
              shortOldName, ConfigConstants.CONFIG_KEY_REMOTE);
          if (oldRemote != null) {
            repoConfig.setString(
                ConfigConstants.CONFIG_BRANCH_SECTION, newName,
                ConfigConstants.CONFIG_KEY_REMOTE, oldRemote);
          }
          String oldMerge = repoConfig.getString(
              ConfigConstants.CONFIG_BRANCH_SECTION,
              shortOldName, ConfigConstants.CONFIG_KEY_MERGE);
          if (oldMerge != null) {
            repoConfig.setString(
                ConfigConstants.CONFIG_BRANCH_SECTION, newName,
                ConfigConstants.CONFIG_KEY_MERGE, oldMerge);
          }
          repoConfig
              .unsetSection(
                  ConfigConstants.CONFIG_BRANCH_SECTION,
                  shortOldName);
          repoConfig.save();
        }

      } else
        throw new JGitInternalException(MessageFormat.format(JGitText
            .get().renameBranchUnexpectedResult, renameResult
View Full Code Here

    if (monitor != null)
      clone.setProgressMonitor(monitor);
    Repository subRepo = clone.call().getRepository();

    // Save submodule URL to parent repository's config
    StoredConfig config = repo.getConfig();
    config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path,
        ConfigConstants.CONFIG_KEY_URL, resolvedUri);
    try {
      config.save();
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    }

    // Save path and URL to parent repository's .gitmodules file
View Full Code Here

    try {
      SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
      if (!paths.isEmpty())
        generator.setFilter(PathFilterGroup.createFromStrings(paths));
      StoredConfig config = repo.getConfig();
      List<String> initialized = new ArrayList<String>();
      while (generator.next()) {
        // Ignore entry if URL is already present in config file
        if (generator.getConfigUrl() != null)
          continue;

        String path = generator.getPath();
        // Copy 'url' and 'update' fields from .gitmodules to config
        // file
        String url = generator.getRemoteUrl();
        String update = generator.getModulesUpdate();
        if (url != null)
          config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
              path, ConfigConstants.CONFIG_KEY_URL, url);
        if (update != null)
          config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
              path, ConfigConstants.CONFIG_KEY_UPDATE, update);
        if (url != null || update != null)
          initialized.add(path);
      }
      // Save repository config if any values were updated
      if (!initialized.isEmpty())
        config.save();
      return initialized;
    } catch (IOException e) {
      throw new JGitInternalException(e.getMessage(), e);
    } catch (ConfigInvalidException e) {
      throw new JGitInternalException(e.getMessage(), e);
View Full Code Here

    try {
      SubmoduleWalk generator = SubmoduleWalk.forIndex(repo);
      if (!paths.isEmpty())
        generator.setFilter(PathFilterGroup.createFromStrings(paths));
      Map<String, String> synced = new HashMap<String, String>();
      StoredConfig config = repo.getConfig();
      while (generator.next()) {
        String remoteUrl = generator.getRemoteUrl();
        if (remoteUrl == null)
          continue;

        String path = generator.getPath();
        config.setString(ConfigConstants.CONFIG_SUBMODULE_SECTION,
            path, ConfigConstants.CONFIG_KEY_URL, remoteUrl);
        synced.put(path, remoteUrl);

        Repository subRepo = generator.getRepository();
        if (subRepo == null)
          continue;

        StoredConfig subConfig = subRepo.getConfig();
        // Get name of remote associated with current branch and
        // fall back to default remote name as last resort
        String branch = getHeadBranch(subRepo);
        String remote = null;
        if (branch != null)
          remote = subConfig.getString(
              ConfigConstants.CONFIG_BRANCH_SECTION, branch,
              ConfigConstants.CONFIG_KEY_REMOTE);
        if (remote == null)
          remote = Constants.DEFAULT_REMOTE_NAME;

        subConfig.setString(ConfigConstants.CONFIG_REMOTE_SECTION,
            remote, ConfigConstants.CONFIG_KEY_URL, remoteUrl);
        subConfig.save();
      }
      if (!synced.isEmpty())
        config.save();
      return synced;
    } catch (IOException e) {
View Full Code Here

        updateWithBundleTimestamp(repo, bundle);
    }

    private void updateWithBundleTimestamp(Repository repo, Bundle bundle) throws IOException
    {
        StoredConfig config = repo.getConfig();
        config.setLong("speakeasy", null, BUNDLELASTMODIFIED, bundle.getLastModified());
        config.save();
    }
View Full Code Here

                RefSpec branchSpec = new RefSpec(prefixedReleaseName + ":" + Constants.R_HEADS + prefixedReleaseName);
                git.push().setRemote("origin").setRefSpecs(branchSpec).call();
                git.fetch().setRemote("origin").call();

                //setup tracking
                StoredConfig config = git.getRepository().getConfig();
                config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, prefixedReleaseName, ConfigConstants.CONFIG_KEY_REMOTE, "origin");
                config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, prefixedReleaseName, ConfigConstants.CONFIG_KEY_MERGE, Constants.R_HEADS + prefixedReleaseName);
                config.save();
            }
           
            return newBranch;

        }
View Full Code Here

        return git.getRepository().getConfig().getString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER);
    }

    public void setMaster(String branchName) throws IOException
    {
        StoredConfig config = git.getRepository().getConfig();
        config.setString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER, branchName);
        config.save();
    }
View Full Code Here

        config.save();
    }

    public void setDevelop(String branchName) throws IOException
    {
        StoredConfig config = git.getRepository().getConfig();
        config.setString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, JGitFlowConstants.DEVELOP_KEY, branchName);
        config.save();
    }
View Full Code Here

        return (null != val) ? val : "";
    }

    public void setPrefix(String prefixName, String prefixValue) throws IOException
    {
        StoredConfig config = git.getRepository().getConfig();
        if(getPrefixNames().contains(prefixName))
        {
            config.setString(JGitFlowConstants.SECTION, JGitFlowConstants.PREFIX_SUB, prefixName, prefixValue);
            config.save();
        }
       
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.lib.StoredConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.