private static void visit( File directory ) throws IOException, RefNotFoundException, DetachedHeadException, WrongRepositoryStateException, InvalidRemoteException, InvalidConfigurationException, CanceledException { for ( final File child : directory.listFiles() ) { if ( child.isDirectory() ) { visit( child ); } final String name = child.getName(); if ( name.equals( ".git" ) ) { Thread t = new Thread( new Runnable() { public void run() { try { Git git = Git.open( child.getParentFile() ); PullResult pullResult = git.pull().call(); System.out.println( "pulled on " + child.getParentFile().getName() + ", pullResult = " + pullResult.isSuccessful() + ", " + pullResult.getFetchedFrom() + ", fetch messages: " + pullResult.getFetchResult().getMessages() ); } catch ( Exception e ) { e.printStackTrace(); } } } ); t.start(); } } }
@Test(expected = TransferFailedException.class) public void testGitApiException() throws Exception { new AbstractGitWagon() { @Override protected GitUri buildGitUri(final URI gitUri) throws IOException, URISyntaxException { final String branchName = gitUri.getQuery(); final String asciiUriString = gitUri.toASCIIString(); final String gitRepositoryUri = asciiUriString.substring(0, asciiUriString.indexOf('?')); final String resource = gitUri.getFragment(); return new GitUri(gitRepositoryUri, branchName, resource); } @Override protected File getFileForResource(final String resourceName) throws GitAPIException, IOException, URISyntaxException { throw new DetachedHeadException(); } }.resourceExists("fail"); }
public Git call(final GitOperationsStep gitOperationsStep, Git git, CredentialsProvider cp, String gitRepoUrl, File gitRepoFolder) throws IllegalArgumentException, IOException, WrongRepositoryStateException, InvalidConfigurationException, DetachedHeadException, InvalidRemoteException, CanceledException, RefNotFoundException, NoHeadException, TransportException, GitAPIException { git.pull().setCredentialsProvider(cp).setRebase(rebase).call(); return git; }
public static void main( String[] args ) throws IOException, RefNotFoundException, DetachedHeadException, WrongRepositoryStateException, InvalidRemoteException, InvalidConfigurationException, CanceledException { visit( new File( "C:\\workingcopy\\phet-little-gits" ) ); }