You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by im...@apache.org on 2014/07/18 18:40:39 UTC

[4/7] git commit: fix formatting

fix formatting


Project: http://git-wip-us.apache.org/repos/asf/maven-scm/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-scm/commit/f2bc97d3
Tree: http://git-wip-us.apache.org/repos/asf/maven-scm/tree/f2bc97d3
Diff: http://git-wip-us.apache.org/repos/asf/maven-scm/diff/f2bc97d3

Branch: refs/heads/master
Commit: f2bc97d3a2e34848459ac8a52bd7f214ac0285d6
Parents: da08837
Author: imod <do...@fortysix.ch>
Authored: Fri Jul 18 06:20:41 2014 +0200
Committer: imod <do...@fortysix.ch>
Committed: Fri Jul 18 06:20:41 2014 +0200

----------------------------------------------------------------------
 ...GitCheckInCommandCommitterAuthorTckTest.java | 267 +++++++++----------
 1 file changed, 133 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-scm/blob/f2bc97d3/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java
----------------------------------------------------------------------
diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java
index 37e1842..87bb9c0 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-jgit/src/test/java/org/apache/maven/scm/provider/git/jgit/command/checkin/JGitCheckInCommandCommitterAuthorTckTest.java
@@ -61,157 +61,156 @@ public class JGitCheckInCommandCommitterAuthorTckTest
     protected void deleteDirectory( File directory )
         throws IOException
     {
-        if( directory.exists() )
+        if ( directory.exists() )
         {
             FileUtils.delete( directory, FileUtils.RECURSIVE | FileUtils.RETRY );
         }
     }
-    
+
     @Override
-    public void testCheckInCommandTest() throws Exception 
+    public void testCheckInCommandTest()
+        throws Exception
     {
-    	File fooJava = new File( getWorkingCopy(), "src/main/java/Foo.java" );
-    	assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() );
+        File fooJava = new File( getWorkingCopy(), "src/main/java/Foo.java" );
+        assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() );
 
-    	Git git = Git.open( getWorkingCopy() );
+        Git git = Git.open( getWorkingCopy() );
 
-    	RevCommit head = getHeadCommit( git.getRepository() );
-    	// Mark created the test repo...
-    	assertEquals( "Mark Struberg", head.getCommitterIdent().getName() );
-    	JGitUtils.closeRepo(git);
+        RevCommit head = getHeadCommit( git.getRepository() );
+        // Mark created the test repo...
+        assertEquals( "Mark Struberg", head.getCommitterIdent().getName() );
+        JGitUtils.closeRepo( git );
 
         createAndCommitFile( fooJava, null );
-        
-        // change user in config 
+
+        // change user in config
         git = Git.open( getWorkingCopy() );
         StoredConfig config = git.getRepository().getConfig();
-        unsetConfig(config);
-		config.setString( "user", null, "name", "Dominik" );
-		config.setString( "user", null, "email", "domi@mycomp.com" );
-		config.save();
-        
-		// make a commit
-		createAndCommitFile( fooJava, null );
-		
-		// check new commit is done with new user in config
-    	head = getHeadCommit( git.getRepository() );
-    	assertEquals( "Dominik", head.getCommitterIdent().getName() );
-    	assertEquals( "Dominik", head.getAuthorIdent().getName() );
-    	assertEquals( "domi@mycomp.com", head.getAuthorIdent().getEmailAddress() );
-    	assertEquals( "domi@mycomp.com", head.getCommitterIdent().getEmailAddress() );
-    	JGitUtils.closeRepo( git );
-
-    	
-        // change user in config 
+        unsetConfig( config );
+        config.setString( "user", null, "name", "Dominik" );
+        config.setString( "user", null, "email", "domi@mycomp.com" );
+        config.save();
+
+        // make a commit
+        createAndCommitFile( fooJava, null );
+
+        // check new commit is done with new user in config
+        head = getHeadCommit( git.getRepository() );
+        assertEquals( "Dominik", head.getCommitterIdent().getName() );
+        assertEquals( "Dominik", head.getAuthorIdent().getName() );
+        assertEquals( "domi@mycomp.com", head.getAuthorIdent().getEmailAddress() );
+        assertEquals( "domi@mycomp.com", head.getCommitterIdent().getEmailAddress() );
+        JGitUtils.closeRepo( git );
+
+        // change user in config
         git = Git.open( getWorkingCopy() );
         config = git.getRepository().getConfig();
-        unsetConfig(config);
-		config.setString( "user", null, "name", "dbartholdi" );
-		config.save();
-
-		// make a change
-		createAndCommitFile( fooJava, null );
-		
-		// check new commit is done with new user in config
-    	head = getHeadCommit( git.getRepository() );
-    	assertEquals( "dbartholdi", head.getCommitterIdent().getName() );
-    	assertFalse( "no mail domain is configured, git system default should be used", head.getCommitterIdent().getEmailAddress().contains( "dbartholdi" ) );
-    	JGitUtils.closeRepo( git );		
-    	
-    	
-    	// unset a user and maven user but set default mail domain 
+        unsetConfig( config );
+        config.setString( "user", null, "name", "dbartholdi" );
+        config.save();
+
+        // make a change
+        createAndCommitFile( fooJava, null );
+
+        // check new commit is done with new user in config
+        head = getHeadCommit( git.getRepository() );
+        assertEquals( "dbartholdi", head.getCommitterIdent().getName() );
+        assertFalse( "no mail domain is configured, git system default should be used",
+                     head.getCommitterIdent().getEmailAddress().contains( "dbartholdi" ) );
+        JGitUtils.closeRepo( git );
+
+        // unset a user and maven user but set default mail domain
         git = Git.open( getWorkingCopy() );
         config = git.getRepository().getConfig();
-        unsetConfig(config);
-		config.setString( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "comp.com" );
-		config.save();
-
-		// make a change with an user on the commandline
-		createAndCommitFile( fooJava, "dude" );
-				
-		// check new commit is done with new maven user in config
-    	head = getHeadCommit( git.getRepository() );
-    	assertEquals( "dude", head.getCommitterIdent().getName() );
-    	assertEquals( "dude@comp.com", head.getCommitterIdent().getEmailAddress() );
-    	assertEquals( "dude", head.getAuthorIdent().getName() );
-    	assertEquals( "dude@comp.com", head.getAuthorIdent().getEmailAddress() );    	
-    	JGitUtils.closeRepo( git );		
-
-    	// unset a user and maven user but set default mail domain 
+        unsetConfig( config );
+        config.setString( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "comp.com" );
+        config.save();
+
+        // make a change with an user on the commandline
+        createAndCommitFile( fooJava, "dude" );
+
+        // check new commit is done with new maven user in config
+        head = getHeadCommit( git.getRepository() );
+        assertEquals( "dude", head.getCommitterIdent().getName() );
+        assertEquals( "dude@comp.com", head.getCommitterIdent().getEmailAddress() );
+        assertEquals( "dude", head.getAuthorIdent().getName() );
+        assertEquals( "dude@comp.com", head.getAuthorIdent().getEmailAddress() );
+        JGitUtils.closeRepo( git );
+
+        // unset a user and maven user but set default mail domain
         git = Git.open( getWorkingCopy() );
         config = git.getRepository().getConfig();
-        unsetConfig(config);
-		config.setString( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "anycomp.com" );
-		config.save();
-
-		// make a change with no username given
-		createAndCommitFile( fooJava, null );
-				
-		// check new commit does not contain the configured email domain
-    	head = getHeadCommit( git.getRepository() );
-    	assertFalse( head.getCommitterIdent().getEmailAddress().contains("anycomp.com") );
-    	assertFalse( head.getAuthorIdent().getEmailAddress().contains("anycomp.com") );
-    	JGitUtils.closeRepo( git );	
-    	
-    	// unset a user and full maven section 
+        unsetConfig( config );
+        config.setString( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "anycomp.com" );
+        config.save();
+
+        // make a change with no username given
+        createAndCommitFile( fooJava, null );
+
+        // check new commit does not contain the configured email domain
+        head = getHeadCommit( git.getRepository() );
+        assertFalse( head.getCommitterIdent().getEmailAddress().contains( "anycomp.com" ) );
+        assertFalse( head.getAuthorIdent().getEmailAddress().contains( "anycomp.com" ) );
+        JGitUtils.closeRepo( git );
+
+        // unset a user and full maven section
         git = Git.open( getWorkingCopy() );
         config = git.getRepository().getConfig();
-        unsetConfig(config);
-		config.save();
-
-		// make a change with an user on the commandline
-		createAndCommitFile( fooJava, "dundy" );
-				
-		// check new commit is done with new maven user in config
-    	head = getHeadCommit( git.getRepository() );
-    	assertEquals( "dundy", head.getCommitterIdent().getName() );
-    	assertEquals( "dundy", head.getAuthorIdent().getName() );
-    	assertTrue( "the maven user (from parameter) name must be in the committer mail when nothing else is configured", head.getCommitterIdent().getEmailAddress().contains( "dundy" ) );
-    	assertTrue( "the user name (from parameter) must be in the author mail when nothing else is configured", head.getAuthorIdent().getEmailAddress().contains( "dundy" ) );
-    	JGitUtils.closeRepo( git );
-    	
-    	
-    	// unset all configs 
+        unsetConfig( config );
+        config.save();
+
+        // make a change with an user on the commandline
+        createAndCommitFile( fooJava, "dundy" );
+
+        // check new commit is done with new maven user in config
+        head = getHeadCommit( git.getRepository() );
+        assertEquals( "dundy", head.getCommitterIdent().getName() );
+        assertEquals( "dundy", head.getAuthorIdent().getName() );
+        assertTrue( "the maven user (from parameter) name must be in the committer mail when nothing else is configured",
+                    head.getCommitterIdent().getEmailAddress().contains( "dundy" ) );
+        assertTrue( "the user name (from parameter) must be in the author mail when nothing else is configured",
+                    head.getAuthorIdent().getEmailAddress().contains( "dundy" ) );
+        JGitUtils.closeRepo( git );
+
+        // unset all configs
         git = Git.open( getWorkingCopy() );
         config = git.getRepository().getConfig();
-        unsetConfig(config);
-		config.save();
-
-		// make a change with no user on the commandline
-		createAndCommitFile( fooJava, null );
-				
-		// check new commit is has a committer/author with email set
-    	head = getHeadCommit( git.getRepository() );
-    	assertNotNull( head.getCommitterIdent().getName() );
-    	assertNotNull( head.getAuthorIdent().getName() );
-    	assertNotNull( head.getCommitterIdent().getEmailAddress() );
-    	assertNotNull( head.getAuthorIdent().getEmailAddress() );
-    	JGitUtils.closeRepo( git );
+        unsetConfig( config );
+        config.save();
+
+        // make a change with no user on the commandline
+        createAndCommitFile( fooJava, null );
+
+        // check new commit is has a committer/author with email set
+        head = getHeadCommit( git.getRepository() );
+        assertNotNull( head.getCommitterIdent().getName() );
+        assertNotNull( head.getAuthorIdent().getName() );
+        assertNotNull( head.getCommitterIdent().getEmailAddress() );
+        assertNotNull( head.getAuthorIdent().getEmailAddress() );
+        JGitUtils.closeRepo( git );
     }
 
     /**
-     * make sure the local .gitconfig is in a clean state 
+     * make sure the local .gitconfig is in a clean state
      */
-	private void unsetConfig(StoredConfig config) {
-		config.unsetSection( "user", null );
-		config.unset( "user", null, "name" );
-		// somehow unset does not always work on "user"
-		config.setString("user", null, "name", null);
-		config.setString("user", null, "email", null);
-		config.unsetSection( JGitCheckInCommand.GIT_MAVEN_SECTION, null );
-	}
-    
-    
-    
-
-	private void createAndCommitFile(File file, String username) throws Exception,
-			ScmException, IOException {
-		createFooJava( file );
+    private void unsetConfig( StoredConfig config )
+    {
+        config.unsetSection( "user", null );
+        config.unset( "user", null, "name" );
+        // somehow unset does not always work on "user"
+        config.setString( "user", null, "name", null );
+        config.setString( "user", null, "email", null );
+        config.unsetSection( JGitCheckInCommand.GIT_MAVEN_SECTION, null );
+    }
+
+    private void createAndCommitFile( File file, String username )
+        throws Exception, ScmException, IOException
+    {
+        createFooJava( file );
 
         ScmRepository scmRepository = getScmRepository();
-        scmRepository.getProviderRepository().setUser(username);
-		AddScmResult addResult = getScmManager().add( scmRepository,
-                                                      new ScmFileSet( getWorkingCopy(), "**/*.java" ) );
+        scmRepository.getProviderRepository().setUser( username );
+        AddScmResult addResult = getScmManager().add( scmRepository, new ScmFileSet( getWorkingCopy(), "**/*.java" ) );
 
         assertResultIsSuccess( addResult );
 
@@ -219,20 +218,20 @@ public class JGitCheckInCommandCommitterAuthorTckTest
             getScmManager().checkIn( scmRepository, new ScmFileSet( getWorkingCopy(), "**/Foo.java" ), "Commit message" );
 
         assertResultIsSuccess( result );
-	}
-    
-    
-    private RevCommit getHeadCommit(Repository repository) throws Exception
+    }
+
+    private RevCommit getHeadCommit( Repository repository )
+        throws Exception
     {
-		RevWalk rw = new RevWalk(repository);
-    	AnyObjectId headId = repository.resolve(Constants.HEAD);
-    	RevCommit head = rw.parseCommit(headId);
-    	rw.release();;
-		return head;
+        RevWalk rw = new RevWalk( repository );
+        AnyObjectId headId = repository.resolve( Constants.HEAD );
+        RevCommit head = rw.parseCommit( headId );
+        rw.release();
+        return head;
     }
-    
+
     private void createFooJava( File fooJava )
-            throws Exception
+        throws Exception
     {
         FileWriter output = new FileWriter( fooJava );