createAndCommitFile( fooJava, null );
// 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
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
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
git = Git.open( getWorkingCopy() );
config = git.getRepository().getConfig();
unsetConfig( config );
config.setString( "user", null, "name", "dbartholdi" );
config.setBoolean( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_FORCE, true );
config.setString( JGitCheckInCommand.GIT_MAVEN_SECTION, null, JGitCheckInCommand.GIT_MAILDOMAIN, "anycomp.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@anycomp.com", head.getCommitterIdent().getEmailAddress() );
assertEquals( "dude", head.getAuthorIdent().getName() );
assertEquals( "dude@anycomp.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
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
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