/** * Lets try detect the github organisation level configuration for a project. * <p> * This lets us have a shared updatebot configuration across repositories within a github organisation * * @return null if it cannot be found */ protected static RepositoryConfig findGithubOrganisationConfig(Configuration configuration, File sourceDir) throws IOException { String gitCloneURL = null; try { gitCloneURL = GitHelpers.extractGitUrl(sourceDir); } catch (IOException e) { // ignore } return loadGithubOrganisationConfig(configuration, gitCloneURL); }
public static Repository getGitRepository(MavenProject project) throws IOException { MavenProject rootProject = MavenUtil.getRootProject(project); File baseDir = rootProject.getBasedir(); if (baseDir == null) { baseDir = project.getBasedir(); } if (baseDir == null) { // TODO: Why is this check needed ? baseDir = new File(System.getProperty("basedir", ".")); } File gitFolder = GitHelpers.findGitFolder(baseDir); if (gitFolder == null) { // No git repository found return null; } FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository = builder .readEnvironment() .setGitDir(gitFolder) .build(); return repository; }
/** * Lets try detect the github organisation level configuration for a project. * <p> * This lets us have a shared updatebot configuration across repositories within a github organisation * * @return null if it cannot be found */ protected static RepositoryConfig findGithubOrganisationConfig(Configuration configuration, File sourceDir) throws IOException { String gitCloneURL = null; try { gitCloneURL = GitHelpers.extractGitUrl(sourceDir); } catch (IOException e) { // ignore } return loadGithubOrganisationConfig(configuration, gitCloneURL); }
/** * Returns the git repository for the current folder or null if none can be found */ public static Repository findRepository(File baseDir) throws IOException { File gitFolder = io.fabric8.utils.GitHelpers.findGitFolder(baseDir); if (gitFolder == null) { // No git repository found return null; } FileRepositoryBuilder builder = new FileRepositoryBuilder(); Repository repository = builder .readEnvironment() .setGitDir(gitFolder) .build(); return repository; }
public static String findGitUrl(Session session, File dir) { try { return GitHelpers.extractGitUrl(dir); } catch (IOException e) { session.getLogger().warn("Could not detect git url from directory: " + dir + ". " + e); return null; } }
/** * Returns the git repository configuration details * * @param repositoryConfig * @param sourceDir * @return * @throws IOException */ public static GitRepositoryConfig getGitHubRepositoryDetails(RepositoryConfig repositoryConfig, File sourceDir) throws IOException { String cloneUrl = GitHelpers.extractGitUrl(sourceDir); if (cloneUrl != null) { // lets remove any user/password if using HTTPS cloneUrl = GitHelper.removeUsernamePassword(cloneUrl); return repositoryConfig.getRepositoryDetails(cloneUrl); } return null; } }
/** * Returns the git repository configuration details * * @param repositoryConfig * @param sourceDir * @return * @throws IOException */ public static GitRepositoryConfig getGitHubRepositoryDetails(RepositoryConfig repositoryConfig, File sourceDir) throws IOException { String cloneUrl = GitHelpers.extractGitUrl(sourceDir); if (cloneUrl != null) { // lets remove any user/password if using HTTPS cloneUrl = GitHelper.removeUsernamePassword(cloneUrl); return repositoryConfig.getRepositoryDetails(cloneUrl); } return null; } }
if (config != null) { String configText = config.getContents(); gitUrlText = GitHelpers.extractGitUrl(configText);
if (config != null) { String configText = config.getContents(); gitUrlText = GitHelpers.extractGitUrl(configText);
gitUrl = GitHelpers.extractGitUrl(basedir);
url = GitHelpers.extractGitUrl(dir); } catch (IOException e) { throw new ParameterException("Could not find the git clone URL in " + dir + ". " + e, e);
url = GitHelpers.extractGitUrl(dir); } catch (IOException e) { throw new ParameterException("Could not find the git clone URL in " + dir + ". " + e, e);