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 public void deleteFailed() throws Exception { when(deleteTagCommand.setTags(ANY_NAME)).thenReturn(deleteTagCommand); when(git.tagDelete()).thenReturn(deleteTagCommand); final GitAPIException expected = new CanceledException(ANY_MESSAGE); doThrow(expected).when(deleteTagCommand).call(); try { tag.delete(); fail("Exception expected!"); } catch (final SCMException e) { assertEquals("Remote tag 'anyName' could not be deleted!", e.getMessage()); assertSame(expected, e.getCause()); } }
@Test public void saveAtHEADFailed() throws Exception { prepareTagAndPush(); final GitAPIException expected = new CanceledException(ANY_MESSAGE); doThrow(expected).when(tagCommand).call(); try { tag.tagAndPush(); fail("Exception expected"); } catch (final SCMException e) { assertEquals("Ref 'anyName' could be saved at HEAD!", e.getMessage()); assertSame(expected, e.getCause()); } }
@Test public void tagAndPushFailed() throws Exception { prepareTagAndPush(); final GitAPIException expected = new CanceledException(ANY_MESSAGE); doThrow(expected).when(pushCommand).call(); try { tag.tagAndPush(); fail("Exception expected"); } catch (final SCMException e) { assertEquals("Tag 'anyName' could not be pushed!", e.getMessage()); assertSame(expected, e.getCause()); } }
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" ) ); }