Java Code Examples for org.eclipse.jgit.api.errors.GitAPIException#printStackTrace()
The following examples show how to use
org.eclipse.jgit.api.errors.GitAPIException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JGitController.java From spring-boot-demo with MIT License | 6 votes |
/** * 克隆 * * @return */ @RequestMapping("/clone") public String clone() { String result; try { Git.cloneRepository() .setURI("https://github.com/smltq/blog.git") .setDirectory(new File("/blog")) .call(); result = "克隆成功了!"; } catch (GitAPIException e) { result = e.getMessage(); e.printStackTrace(); } return result; }
Example 2
Source File: GitUtils.java From gitPic with MIT License | 6 votes |
/** * 获取remote URI * * @param rep * @return */ public static String getRemoteUri(Repository rep) { Git git = new Git(rep); List<RemoteConfig> remoteConfigList; try { remoteConfigList = git.remoteList().call(); } catch (GitAPIException e) { e.printStackTrace(); logger.error(e.getMessage()); throw new TipException("获取RemoteUri异常"); } if (null != remoteConfigList && remoteConfigList.size() > 0) { if (remoteConfigList.get(0).getURIs().size() <= 0) { throw new TipException("该分支不存在远程仓库"); } return remoteConfigList.get(0).getURIs().get(0).toString(); } return ""; }
Example 3
Source File: GitRepository.java From CardinalPGM with MIT License | 6 votes |
@Override public void refreshRepo() throws RotationLoadException, IOException { try { if (git == null) { if (new File(getPath() + File.separator + ".git").exists()) this.git = Git.open(new File(getPath())); else this.git = ((CloneCommand) addCredentials( Git.cloneRepository().setURI(gitUrl.toString()).setDirectory(new File(getPath())))).call(); } git.clean().call(); addCredentials(git.fetch()).call(); git.reset().setRef("@{upstream}").setMode(ResetCommand.ResetType.HARD).call(); } catch (GitAPIException e) { e.printStackTrace(); throw new RotationLoadException("Could not load git repository: " + gitUrl); } super.refreshRepo(); }
Example 4
Source File: UIGit.java From hop with Apache License 2.0 | 5 votes |
@Override public List<String> getTags() { try { return git.tagList().call() .stream().map( ref -> Repository.shortenRefName( ref.getName() ) ) .collect( Collectors.toList() ); } catch ( GitAPIException e ) { e.printStackTrace(); } return null; }
Example 5
Source File: WorldRepository.java From VoxelGamesLibv2 with MIT License | 5 votes |
public void cloneRepo() { try { Git git = Git.cloneRepository().setURI(url).setDirectory(worldsDir).call(); } catch (GitAPIException e) { e.printStackTrace(); } }
Example 6
Source File: GitWrapper.java From Stringlate with MIT License | 5 votes |
public static boolean cloneRepo(final String uri, final File cloneTo, final String branch, final GitCloneProgressCallback callback) { Git result = null; try { final CloneCommand clone = Git.cloneRepository() .setURI(uri).setDirectory(cloneTo) .setBare(false).setRemote(REMOTE_NAME).setNoCheckout(false) .setCloneAllBranches(false).setCloneSubmodules(false) .setProgressMonitor(callback); if (!branch.isEmpty()) { if (branch.contains("/")) { clone.setBranch(branch.substring(branch.lastIndexOf('/') + 1)); } else { clone.setBranch(branch); } } result = clone.call(); return true; } catch (GitAPIException e) { e.printStackTrace(); } finally { if (result != null) { result.close(); } } return false; }
Example 7
Source File: GitRepository.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Collection<GitBranch> getBranches() { try { return StreamSupport .stream(git.branchList().call().spliterator(), false) .map(ref -> new GitBranch(ref)) .collect(Collectors.toSet()); } catch (GitAPIException e) { e.printStackTrace(); return new HashSet<>(); } }
Example 8
Source File: GitRepository.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Collection<GitTag> getTags() { try { return StreamSupport .stream(git.tagList().call().spliterator(), false) .map(ref -> new GitTag(!ref.isPeeled() ? ref : repo.peel(ref))) .collect(Collectors.toSet()); } catch (GitAPIException e) { e.printStackTrace(); return new HashSet<>(); } }
Example 9
Source File: NextMojo.java From multi-module-maven-release-plugin with MIT License | 5 votes |
@Override public void execute() throws MojoExecutionException, MojoFailureException { Log log = getLog(); try { configureJsch(log); Set<GitOperations> gitOperations = EnumSet.noneOf(GitOperations.class); if (pullTags) { gitOperations.add(GitOperations.PULL_TAGS); } LocalGitRepo repo = new LocalGitRepo.Builder() .remoteGitOperationsAllowed(gitOperations) .remoteGitUrl(getRemoteUrlOrNullIfNoneSet(project.getOriginalModel().getScm(), project.getModel().getScm())) .credentialsProvider(getCredentialsProvider(log)) .buildFromCurrentDir(); ResolverWrapper resolverWrapper = new ResolverWrapper(factory, artifactResolver, remoteRepositories, localRepository); Reactor reactor = Reactor.fromProjects(log, repo, project, projects, buildNumber, modulesToForceRelease, noChangesAction, resolverWrapper, versionNamer); if (reactor == null) { return; } ReleaseMojo.figureOutTagNamesAndThrowIfAlreadyExists(reactor.getModulesInBuildOrder(), repo, modulesToRelease); } catch (ValidationException e) { printBigErrorMessageAndThrow(log, e.getMessage(), e.getMessages()); } catch (GitAPIException gae) { StringWriter sw = new StringWriter(); gae.printStackTrace(new PrintWriter(sw)); String exceptionAsString = sw.toString(); printBigErrorMessageAndThrow(log, "Could not release due to a Git error", asList("There was an error while accessing the Git repository. The error returned from git was:", gae.getMessage(), "Stack trace:", exceptionAsString)); } }
Example 10
Source File: GitMigrator.java From rtc2gitcli with MIT License | 5 votes |
private void runGitGc() { try { git.gc().call(); } catch (GitAPIException e) { e.printStackTrace(); } finally { git.close(); } }
Example 11
Source File: GitWorker.java From Plugin with MIT License | 5 votes |
private Boolean cloneRepository(File androidGearsDirectory){ try { Git git = Git.cloneRepository() .setURI(REMOTE_SPECS_URL) .setBranch("master") .setDirectory(androidGearsDirectory) .setTimeout(DEFAULT_TIMEOUT) .call(); //Get repos directory File reposDirectory = git.getRepository().getDirectory().getParentFile(); //Close git connection! git.close(); //If everything was created successfully, return true if (reposDirectory != null){ if (reposDirectory.exists()){ if (reposDirectory.list().length > 1){ return true; } } } } catch (GitAPIException e) { e.printStackTrace(); } return false; }
Example 12
Source File: GitClient.java From steady with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ public Map<String, String> getCommitLogEntries( Set<String> _revs ) { final Map<String, String> hits = new HashMap<String, String>(); if (!_revs.isEmpty() ) { try { Repository repository = this.getRepositoryFromPath( null ); RevWalk walk = new RevWalk( repository ); //walk.setRevFilter(RevFilter); RevCommit commit = null; Git git = new Git( repository ); Iterable<RevCommit> logs = git.log().call(); Iterator<RevCommit> i = logs.iterator(); String commitId = null; String commitMsg = null; // iterate over all commits while ( i.hasNext() ) { commit = walk.parseCommit( i.next() ); commitId = commit.getName(); commitMsg = commit.getFullMessage(); // iterate over all revisions to search for for ( String sid : _revs ) { if(sid.contains(":")){ sid= sid.substring(0,sid.indexOf(":")-1); } if ( !sid.equals( "" ) && sid.equals( commitId ) ) { hits.put( commitId , commitMsg ); continue; } } } } catch ( UnknownHostException e ) { GitClient.log.error( "Proxy issues?" ); e.printStackTrace(); } catch ( IOException ioe ) { GitClient.log.error( "Something went wrong with the I/O" ); ioe.printStackTrace(); } catch ( GitAPIException ge ) { GitClient.log.error( "Something went wrong with the GIT API" ); ge.printStackTrace(); } } return hits; }