/** * Gets a reference to a local branch with the given name * @param git The git instance to use * @param branchName The name of the remote branch * @return A reference to the local branch or null * @throws JGitFlowIOException */ public static Ref getLocalBranch(Git git, String branchName) throws JGitFlowIOException { try { Ref ref2check = git.getRepository().getRef(branchName); Ref local = null; if (ref2check != null && ref2check.getName().startsWith(Constants.R_HEADS)) { local = ref2check; } return local; } catch (IOException e) { throw new JGitFlowIOException(e); } }
/** * Gets a reference to a local branch with the given name * * @param git The git instance to use * @param branchName The name of the remote branch * @return A reference to the local branch or null * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public static Ref getLocalBranch(Git git, String branchName) throws JGitFlowIOException { try { Ref ref2check = git.getRepository().getRef(branchName); Ref local = null; if (ref2check != null && ref2check.getName().startsWith(Constants.R_HEADS)) { local = ref2check; } return local; } catch (IOException e) { throw new JGitFlowIOException(e); } }
/** * Gets a reference to a local branch with the given name * * @param git The git instance to use * @param branchName The name of the remote branch * @return A reference to the local branch or null * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public static Ref getLocalBranch(Git git, String branchName) throws JGitFlowIOException { try { Ref ref2check = git.getRepository().getRef(branchName); Ref local = null; if (ref2check != null && ref2check.getName().startsWith(Constants.R_HEADS)) { local = ref2check; } return local; } catch (IOException e) { throw new JGitFlowIOException(e); } }
/** * Sets the name of the develop branch * @param branchName * @throws JGitFlowIOException */ public void setDevelop(String branchName) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); config.setString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, JGitFlowConstants.DEVELOP_KEY, branchName); try { config.save(); } catch (IOException e) { throw new JGitFlowIOException(e); } }
/** * Sets the value for a given prefix * @param prefixName * @param prefixValue * @throws JGitFlowIOException */ public void setPrefix(String prefixName, String prefixValue) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); if (getPrefixNames().contains(prefixName)) { config.setString(JGitFlowConstants.SECTION, JGitFlowConstants.PREFIX_SUB, prefixName, prefixValue); try { config.save(); } catch (IOException e) { throw new JGitFlowIOException(e); } } } }
/** * Sets the name of the master branch * @param branchName * @throws JGitFlowIOException */ public void setMaster(String branchName) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); config.setString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER, branchName); try { config.save(); } catch (IOException e) { throw new JGitFlowIOException(e); } }
/** * Sets the value for a given prefix * * @param prefixName * @param prefixValue * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public void setPrefix(String prefixName, String prefixValue) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); if (getPrefixNames().contains(prefixName)) { config.setString(JGitFlowConstants.SECTION, JGitFlowConstants.PREFIX_SUB, prefixName, prefixValue); try { config.save(); config.load(); } catch (Exception e) { throw new JGitFlowIOException(e); } } }
/** * Sets the value for a given prefix * * @param prefixName * @param prefixValue * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public void setPrefix(String prefixName, String prefixValue) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); if (getPrefixNames().contains(prefixName)) { config.setString(JGitFlowConstants.SECTION, JGitFlowConstants.PREFIX_SUB, prefixName, prefixValue); try { config.save(); config.load(); } catch (Exception e) { throw new JGitFlowIOException(e); } } }
/** * Sets the name of the master branch * * @param branchName * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public void setMaster(String branchName) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); config.setString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER, branchName); try { config.save(); config.load(); } catch (Exception e) { throw new JGitFlowIOException(e); } }
/** * Sets the name of the master branch * * @param branchName * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public void setMaster(String branchName) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); config.setString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, Constants.MASTER, branchName); try { config.save(); config.load(); } catch (Exception e) { throw new JGitFlowIOException(e); } }
/** * Sets the name of the develop branch * * @param branchName * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public void setDevelop(String branchName) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); config.setString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, JGitFlowConstants.DEVELOP_KEY, branchName); try { config.save(); config.load(); } catch (Exception e) { throw new JGitFlowIOException(e); } }
/** * Sets the name of the develop branch * * @param branchName * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public void setDevelop(String branchName) throws JGitFlowIOException { StoredConfig config = git.getRepository().getConfig(); config.setString(JGitFlowConstants.SECTION, ConfigConstants.CONFIG_BRANCH_SECTION, JGitFlowConstants.DEVELOP_KEY, branchName); try { config.save(); config.load(); } catch (Exception e) { throw new JGitFlowIOException(e); } }
/** * Gets an existing git flow project and returns a JGitFlow instance * * @param projectDir * @return * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public static JGitFlow get(File projectDir) throws JGitFlowIOException { try { RepositoryBuilder rb = new RepositoryBuilder() .readEnvironment() .findGitDir(projectDir); File gitDir = rb.getGitDir(); Git gitRepo = Git.open(gitDir); GitFlowConfiguration gfConfig = new GitFlowConfiguration(gitRepo); return new JGitFlow(gitRepo, gfConfig); } catch (IOException e) { throw new JGitFlowIOException(e); } }
/** * Gets an existing git flow project and returns a JGitFlow instance * * @param projectDir * @return * @throws com.atlassian.jgitflow.core.exception.JGitFlowIOException */ public static JGitFlow get(File projectDir) throws JGitFlowIOException { try { RepositoryBuilder rb = new RepositoryBuilder() .readEnvironment() .findGitDir(projectDir); File gitDir = rb.getGitDir(); Git gitRepo = Git.open(gitDir); GitFlowConfiguration gfConfig = new GitFlowConfiguration(gitRepo); return new JGitFlow(gitRepo, gfConfig); } catch (IOException e) { throw new JGitFlowIOException(e); } }