@ -90,24 +90,28 @@ public class RepoCommandTest extends RepositoryTestCase {
JGitTestUtil . writeTrashFile ( defaultDb , "hello.txt" , "master world" ) ;
JGitTestUtil . writeTrashFile ( defaultDb , "hello.txt" , "master world" ) ;
git . add ( ) . addFilepattern ( "hello.txt" ) . call ( ) ;
git . add ( ) . addFilepattern ( "hello.txt" ) . call ( ) ;
git . commit ( ) . setMessage ( "Second commit" ) . call ( ) ;
git . commit ( ) . setMessage ( "Second commit" ) . call ( ) ;
addRepoToClose ( defaultDb ) ;
notDefaultDb = createWorkRepository ( ) ;
notDefaultDb = createWorkRepository ( ) ;
git = new Git ( notDefaultDb ) ;
git = new Git ( notDefaultDb ) ;
JGitTestUtil . writeTrashFile ( notDefaultDb , "world.txt" , "hello" ) ;
JGitTestUtil . writeTrashFile ( notDefaultDb , "world.txt" , "hello" ) ;
git . add ( ) . addFilepattern ( "world.txt" ) . call ( ) ;
git . add ( ) . addFilepattern ( "world.txt" ) . call ( ) ;
git . commit ( ) . setMessage ( "Initial commit" ) . call ( ) ;
git . commit ( ) . setMessage ( "Initial commit" ) . call ( ) ;
addRepoToClose ( notDefaultDb ) ;
groupADb = createWorkRepository ( ) ;
groupADb = createWorkRepository ( ) ;
git = new Git ( groupADb ) ;
git = new Git ( groupADb ) ;
JGitTestUtil . writeTrashFile ( groupADb , "a.txt" , "world" ) ;
JGitTestUtil . writeTrashFile ( groupADb , "a.txt" , "world" ) ;
git . add ( ) . addFilepattern ( "a.txt" ) . call ( ) ;
git . add ( ) . addFilepattern ( "a.txt" ) . call ( ) ;
git . commit ( ) . setMessage ( "Initial commit" ) . call ( ) ;
git . commit ( ) . setMessage ( "Initial commit" ) . call ( ) ;
addRepoToClose ( groupADb ) ;
groupBDb = createWorkRepository ( ) ;
groupBDb = createWorkRepository ( ) ;
git = new Git ( groupBDb ) ;
git = new Git ( groupBDb ) ;
JGitTestUtil . writeTrashFile ( groupBDb , "b.txt" , "world" ) ;
JGitTestUtil . writeTrashFile ( groupBDb , "b.txt" , "world" ) ;
git . add ( ) . addFilepattern ( "b.txt" ) . call ( ) ;
git . add ( ) . addFilepattern ( "b.txt" ) . call ( ) ;
git . commit ( ) . setMessage ( "Initial commit" ) . call ( ) ;
git . commit ( ) . setMessage ( "Initial commit" ) . call ( ) ;
addRepoToClose ( groupBDb ) ;
resolveRelativeUris ( ) ;
resolveRelativeUris ( ) ;
}
}
@ -239,45 +243,47 @@ public class RepoCommandTest extends RepositoryTestCase {
public void testBareRepo ( ) throws Exception {
public void testBareRepo ( ) throws Exception {
Repository remoteDb = createBareRepository ( ) ;
Repository remoteDb = createBareRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
StringBuilder xmlContent = new StringBuilder ( ) ;
try {
xmlContent . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
StringBuilder xmlContent = new StringBuilder ( ) ;
. append ( "<manifest>" )
xmlContent
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "<manifest>" )
. append ( "<project path=\"foo\" name=\"" )
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( defaultUri )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "\" />" )
. append ( "<project path=\"foo\" name=\"" ) . append ( defaultUri )
. append ( "</manifest>" ) ;
. append ( "\" />" ) . append ( "</manifest>" ) ;
JGitTestUtil . writeTrashFile (
JGitTestUtil . writeTrashFile ( tempDb , "manifest.xml" ,
tempDb , "manifest.xml" , xmlContent . toString ( ) ) ;
xmlContent . toString ( ) ) ;
RepoCommand command = new RepoCommand ( remoteDb ) ;
RepoCommand command = new RepoCommand ( remoteDb ) ;
command
command . setPath (
. setPath ( tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/manifest.xml" )
tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/manifest.xml" )
. setURI ( rootUri )
. setURI ( rootUri ) . call ( ) ;
. call ( ) ;
// Clone it
// Clone it
File directory = createTempDirectory ( "testBareRepo" ) ;
File directory = createTempDirectory ( "testBareRepo" ) ;
Repository localDb = Git . cloneRepository ( ) . setDirectory ( directory )
Repository localDb = Git
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) ) . call ( )
. cloneRepository ( )
. getRepository ( ) ;
. setDirectory ( directory )
// The .gitmodules file should exist
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) )
File gitmodules = new File ( localDb . getWorkTree ( ) , ".gitmodules" ) ;
. call ( )
assertTrue ( "The .gitmodules file should exist" , gitmodules . exists ( ) ) ;
. getRepository ( ) ;
// The first line of .gitmodules file should be expected
// The .gitmodules file should exist
BufferedReader reader = new BufferedReader ( new FileReader (
File gitmodules = new File ( localDb . getWorkTree ( ) , ".gitmodules" ) ;
gitmodules ) ) ;
assertTrue ( "The .gitmodules file should exist" , gitmodules . exists ( ) ) ;
String content = reader . readLine ( ) ;
// The first line of .gitmodules file should be expected
reader . close ( ) ;
BufferedReader reader = new BufferedReader ( new FileReader ( gitmodules ) ) ;
assertEquals (
String content = reader . readLine ( ) ;
"The first line of .gitmodules file should be as expected" ,
reader . close ( ) ;
"[submodule \"foo\"]" , content ) ;
assertEquals (
// The gitlink should be the same as remote head sha1
"The first line of .gitmodules file should be as expected" ,
String gitlink = localDb . resolve ( Constants . HEAD + ":foo" ) . name ( ) ;
"[submodule \"foo\"]" , content ) ;
localDb . close ( ) ;
// The gitlink should be the same as remote head sha1
String remote = defaultDb . resolve ( Constants . HEAD ) . name ( ) ;
String gitlink = localDb . resolve ( Constants . HEAD + ":foo" ) . name ( ) ;
assertEquals ( "The gitlink should be the same as remote head" ,
String remote = defaultDb . resolve ( Constants . HEAD ) . name ( ) ;
remote , gitlink ) ;
assertEquals ( "The gitlink should be the same as remote head" ,
} finally {
remote , gitlink ) ;
tempDb . close ( ) ;
remoteDb . close ( ) ;
}
}
}
@Test
@Test
@ -362,213 +368,213 @@ public class RepoCommandTest extends RepositoryTestCase {
public void testRevisionBare ( ) throws Exception {
public void testRevisionBare ( ) throws Exception {
Repository remoteDb = createBareRepository ( ) ;
Repository remoteDb = createBareRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
StringBuilder xmlContent = new StringBuilder ( ) ;
try {
xmlContent . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
StringBuilder xmlContent = new StringBuilder ( ) ;
. append ( "<manifest>" )
xmlContent . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( "<manifest>" )
. append ( "<default revision=\"" )
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( BRANCH )
. append ( "<default revision=\"" ) . append ( BRANCH )
. append ( "\" remote=\"remote1\" />" )
. append ( "\" remote=\"remote1\" />" )
. append ( "<project path=\"foo\" name=\"" )
. append ( "<project path=\"foo\" name=\"" ) . append ( defaultUri )
. append ( defaultUri )
. append ( "\" />" ) . append ( "</manifest>" ) ;
. append ( "\" />" )
JGitTestUtil . writeTrashFile ( tempDb , "manifest.xml" ,
. append ( "</manifest>" ) ;
xmlContent . toString ( ) ) ;
JGitTestUtil . writeTrashFile (
RepoCommand command = new RepoCommand ( remoteDb ) ;
tempDb , "manifest.xml" , xmlContent . toString ( ) ) ;
command . setPath (
RepoCommand command = new RepoCommand ( remoteDb ) ;
tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/manifest.xml" )
command
. setURI ( rootUri ) . call ( ) ;
. setPath ( tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/manifest.xml" )
// Clone it
. setURI ( rootUri )
File directory = createTempDirectory ( "testRevisionBare" ) ;
. call ( ) ;
Repository localDb = Git . cloneRepository ( ) . setDirectory ( directory )
// Clone it
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) ) . call ( )
File directory = createTempDirectory ( "testRevisionBare" ) ;
. getRepository ( ) ;
Repository localDb = Git
// The gitlink should be the same as oldCommitId
. cloneRepository ( )
String gitlink = localDb . resolve ( Constants . HEAD + ":foo" ) . name ( ) ;
. setDirectory ( directory )
localDb . close ( ) ;
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) )
assertEquals ( "The gitlink is same as remote head" ,
. call ( )
oldCommitId . name ( ) , gitlink ) ;
. getRepository ( ) ;
} finally {
// The gitlink should be the same as oldCommitId
tempDb . close ( ) ;
String gitlink = localDb . resolve ( Constants . HEAD + ":foo" ) . name ( ) ;
remoteDb . close ( ) ;
assertEquals ( "The gitlink is same as remote head" ,
}
oldCommitId . name ( ) , gitlink ) ;
}
}
@Test
@Test
public void testCopyFileBare ( ) throws Exception {
public void testCopyFileBare ( ) throws Exception {
Repository remoteDb = createBareRepository ( ) ;
Repository remoteDb = createBareRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
StringBuilder xmlContent = new StringBuilder ( ) ;
try {
xmlContent . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
StringBuilder xmlContent = new StringBuilder ( ) ;
. append ( "<manifest>" )
xmlContent
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "<manifest>" )
. append ( "<project path=\"foo\" name=\"" )
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( defaultUri )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "\" revision=\"" )
. append ( "<project path=\"foo\" name=\"" ) . append ( defaultUri )
. append ( BRANCH )
. append ( "\" revision=\"" ) . append ( BRANCH ) . append ( "\" >" )
. append ( "\" >" )
. append ( "<copyfile src=\"hello.txt\" dest=\"Hello\" />" )
. append ( "<copyfile src=\"hello.txt\" dest=\"Hello\" />" )
. append ( "</project>" ) . append ( "</manifest>" ) ;
. append ( "</project>" )
JGitTestUtil . writeTrashFile ( tempDb , "manifest.xml" ,
. append ( "</manifest>" ) ;
xmlContent . toString ( ) ) ;
JGitTestUtil . writeTrashFile (
RepoCommand command = new RepoCommand ( remoteDb ) ;
tempDb , "manifest.xml" , xmlContent . toString ( ) ) ;
command . setPath (
RepoCommand command = new RepoCommand ( remoteDb ) ;
tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/manifest.xml" )
command
. setURI ( rootUri ) . call ( ) ;
. setPath ( tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/manifest.xml" )
// Clone it
. setURI ( rootUri )
File directory = createTempDirectory ( "testCopyFileBare" ) ;
. call ( ) ;
Repository localDb = Git . cloneRepository ( ) . setDirectory ( directory )
// Clone it
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) ) . call ( )
File directory = createTempDirectory ( "testCopyFileBare" ) ;
. getRepository ( ) ;
Repository localDb = Git
// The Hello file should exist
. cloneRepository ( )
File hello = new File ( localDb . getWorkTree ( ) , "Hello" ) ;
. setDirectory ( directory )
localDb . close ( ) ;
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) )
assertTrue ( "The Hello file should exist" , hello . exists ( ) ) ;
. call ( )
// The content of Hello file should be expected
. getRepository ( ) ;
BufferedReader reader = new BufferedReader ( new FileReader ( hello ) ) ;
// The Hello file should exist
String content = reader . readLine ( ) ;
File hello = new File ( localDb . getWorkTree ( ) , "Hello" ) ;
reader . close ( ) ;
assertTrue ( "The Hello file should exist" , hello . exists ( ) ) ;
assertEquals ( "The Hello file should have expected content" ,
// The content of Hello file should be expected
"branch world" , content ) ;
BufferedReader reader = new BufferedReader ( new FileReader ( hello ) ) ;
} finally {
String content = reader . readLine ( ) ;
tempDb . close ( ) ;
reader . close ( ) ;
remoteDb . close ( ) ;
assertEquals ( "The Hello file should have expected content" ,
}
"branch world" , content ) ;
}
}
@Test
@Test
public void testReplaceManifestBare ( ) throws Exception {
public void testReplaceManifestBare ( ) throws Exception {
Repository remoteDb = createBareRepository ( ) ;
Repository remoteDb = createBareRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
StringBuilder xmlContent = new StringBuilder ( ) ;
try {
xmlContent . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
StringBuilder xmlContent = new StringBuilder ( ) ;
. append ( "<manifest>" )
xmlContent
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "<manifest>" )
. append ( "<project path=\"foo\" name=\"" )
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( defaultUri )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "\" revision=\"" )
. append ( "<project path=\"foo\" name=\"" ) . append ( defaultUri )
. append ( BRANCH )
. append ( "\" revision=\"" ) . append ( BRANCH ) . append ( "\" >" )
. append ( "\" >" )
. append ( "<copyfile src=\"hello.txt\" dest=\"Hello\" />" )
. append ( "<copyfile src=\"hello.txt\" dest=\"Hello\" />" )
. append ( "</project>" ) . append ( "</manifest>" ) ;
. append ( "</project>" )
JGitTestUtil . writeTrashFile ( tempDb , "old.xml" ,
. append ( "</manifest>" ) ;
xmlContent . toString ( ) ) ;
JGitTestUtil . writeTrashFile ( tempDb , "old.xml" , xmlContent . toString ( ) ) ;
RepoCommand command = new RepoCommand ( remoteDb ) ;
RepoCommand command = new RepoCommand ( remoteDb ) ;
command . setPath ( tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/old.xml" )
command . setPath ( tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/old.xml" )
. setURI ( rootUri ) . call ( ) ;
. setURI ( rootUri )
xmlContent = new StringBuilder ( ) ;
. call ( ) ;
xmlContent
xmlContent = new StringBuilder ( ) ;
. append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
xmlContent . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
. append ( "<manifest>" )
. append ( "<manifest>" )
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "<project path=\"bar\" name=\"" )
. append ( "<project path=\"bar\" name=\"" )
. append ( defaultUri )
. append ( defaultUri )
. append ( "\" revision=\"" )
. append ( "\" revision=\"" )
. append ( BRANCH )
. append ( BRANCH )
. append ( "\" >" )
. append ( "\" >" )
. append ( "<copyfile src=\"hello.txt\" dest=\"Hello.txt\" />" )
. append ( "<copyfile src=\"hello.txt\" dest=\"Hello.txt\" />" )
. append ( "</project>" ) . append ( "</manifest>" ) ;
. append ( "</project>" )
JGitTestUtil . writeTrashFile ( tempDb , "new.xml" ,
. append ( "</manifest>" ) ;
xmlContent . toString ( ) ) ;
JGitTestUtil . writeTrashFile ( tempDb , "new.xml" , xmlContent . toString ( ) ) ;
command = new RepoCommand ( remoteDb ) ;
command = new RepoCommand ( remoteDb ) ;
command . setPath ( tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/new.xml" )
command . setPath ( tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/new.xml" )
. setURI ( rootUri ) . call ( ) ;
. setURI ( rootUri )
// Clone it
. call ( ) ;
File directory = createTempDirectory ( "testReplaceManifestBare" ) ;
// Clone it
Repository localDb = Git . cloneRepository ( ) . setDirectory ( directory )
File directory = createTempDirectory ( "testReplaceManifestBare" ) ;
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) ) . call ( )
Repository localDb = Git
. getRepository ( ) ;
. cloneRepository ( )
// The Hello file should not exist
. setDirectory ( directory )
File hello = new File ( localDb . getWorkTree ( ) , "Hello" ) ;
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) )
assertFalse ( "The Hello file shouldn't exist" , hello . exists ( ) ) ;
. call ( )
// The Hello.txt file should exist
. getRepository ( ) ;
File hellotxt = new File ( localDb . getWorkTree ( ) , "Hello.txt" ) ;
// The Hello file should not exist
assertTrue ( "The Hello.txt file should exist" , hellotxt . exists ( ) ) ;
File hello = new File ( localDb . getWorkTree ( ) , "Hello" ) ;
// The .gitmodules file should have 'submodule "bar"' and shouldn't
assertFalse ( "The Hello file shouldn't exist" , hello . exists ( ) ) ;
// have
// The Hello.txt file should exist
// 'submodule "foo"' lines.
File hellotxt = new File ( localDb . getWorkTree ( ) , "Hello.txt" ) ;
File dotmodules = new File ( localDb . getWorkTree ( ) ,
assertTrue ( "The Hello.txt file should exist" , hellotxt . exists ( ) ) ;
Constants . DOT_GIT_MODULES ) ;
// The .gitmodules file should have 'submodule "bar"' and shouldn't have
localDb . close ( ) ;
// 'submodule "foo"' lines.
BufferedReader reader = new BufferedReader ( new FileReader (
File dotmodules = new File ( localDb . getWorkTree ( ) ,
dotmodules ) ) ;
Constants . DOT_GIT_MODULES ) ;
boolean foo = false ;
BufferedReader reader = new BufferedReader ( new FileReader ( dotmodules ) ) ;
boolean bar = false ;
boolean foo = false ;
while ( true ) {
boolean bar = false ;
String line = reader . readLine ( ) ;
while ( true ) {
if ( line = = null )
String line = reader . readLine ( ) ;
break ;
if ( line = = null )
if ( line . contains ( "submodule \"foo\"" ) )
break ;
foo = true ;
if ( line . contains ( "submodule \"foo\"" ) )
if ( line . contains ( "submodule \"bar\"" ) )
foo = true ;
bar = true ;
if ( line . contains ( "submodule \"bar\"" ) )
}
bar = true ;
reader . close ( ) ;
assertTrue ( "The bar submodule should exist" , bar ) ;
assertFalse ( "The foo submodule shouldn't exist" , foo ) ;
} finally {
tempDb . close ( ) ;
remoteDb . close ( ) ;
}
}
reader . close ( ) ;
assertTrue ( "The bar submodule should exist" , bar ) ;
assertFalse ( "The foo submodule shouldn't exist" , foo ) ;
}
}
@Test
@Test
public void testRemoveOverlappingBare ( ) throws Exception {
public void testRemoveOverlappingBare ( ) throws Exception {
Repository remoteDb = createBareRepository ( ) ;
Repository remoteDb = createBareRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
Repository tempDb = createWorkRepository ( ) ;
StringBuilder xmlContent = new StringBuilder ( ) ;
try {
xmlContent . append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
StringBuilder xmlContent = new StringBuilder ( ) ;
. append ( "<manifest>" )
xmlContent
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "<manifest>" )
. append ( "<project path=\"foo/bar\" name=\"" )
. append ( "<remote name=\"remote1\" fetch=\".\" />" )
. append ( groupBUri )
. append ( "<default revision=\"master\" remote=\"remote1\" />" )
. append ( "\" />" )
. append ( "<project path=\"foo/bar\" name=\"" )
. append ( "<project path=\"a\" name=\"" )
. append ( groupBUri ) . append ( "\" />" )
. append ( groupAUri )
. append ( "<project path=\"a\" name=\"" ) . append ( groupAUri )
. append ( "\" />" )
. append ( "\" />" ) . append ( "<project path=\"foo\" name=\"" )
. append ( "<project path=\"foo\" name=\"" )
. append ( defaultUri ) . append ( "\" />" ) . append ( "</manifest>" ) ;
. append ( defaultUri )
JGitTestUtil . writeTrashFile ( tempDb , "manifest.xml" ,
. append ( "\" />" )
xmlContent . toString ( ) ) ;
. append ( "</manifest>" ) ;
RepoCommand command = new RepoCommand ( remoteDb ) ;
JGitTestUtil . writeTrashFile (
command . setPath (
tempDb , "manifest.xml" , xmlContent . toString ( ) ) ;
tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/manifest.xml" )
RepoCommand command = new RepoCommand ( remoteDb ) ;
. setURI ( rootUri ) . call ( ) ;
command
// Clone it
. setPath ( tempDb . getWorkTree ( ) . getAbsolutePath ( ) + "/manifest.xml" )
File directory = createTempDirectory ( "testRemoveOverlappingBare" ) ;
. setURI ( rootUri )
Repository localDb = Git . cloneRepository ( ) . setDirectory ( directory )
. call ( ) ;
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) ) . call ( )
// Clone it
. getRepository ( ) ;
File directory = createTempDirectory ( "testRemoveOverlappingBare" ) ;
// The .gitmodules file should have 'submodule "foo"' and shouldn't
Repository localDb = Git
// have
. cloneRepository ( )
// 'submodule "foo/bar"' lines.
. setDirectory ( directory )
File dotmodules = new File ( localDb . getWorkTree ( ) ,
. setURI ( remoteDb . getDirectory ( ) . toURI ( ) . toString ( ) )
Constants . DOT_GIT_MODULES ) ;
. call ( )
localDb . close ( ) ;
. getRepository ( ) ;
BufferedReader reader = new BufferedReader ( new FileReader (
// The .gitmodules file should have 'submodule "foo"' and shouldn't have
dotmodules ) ) ;
// 'submodule "foo/bar"' lines.
boolean foo = false ;
File dotmodules = new File ( localDb . getWorkTree ( ) ,
boolean foobar = false ;
Constants . DOT_GIT_MODULES ) ;
boolean a = false ;
BufferedReader reader = new BufferedReader ( new FileReader ( dotmodules ) ) ;
while ( true ) {
boolean foo = false ;
String line = reader . readLine ( ) ;
boolean foobar = false ;
if ( line = = null )
boolean a = false ;
break ;
while ( true ) {
if ( line . contains ( "submodule \"foo\"" ) )
String line = reader . readLine ( ) ;
foo = true ;
if ( line = = null )
if ( line . contains ( "submodule \"foo/bar\"" ) )
break ;
foobar = true ;
if ( line . contains ( "submodule \"foo\"" ) )
if ( line . contains ( "submodule \"a\"" ) )
foo = true ;
a = true ;
if ( line . contains ( "submodule \"foo/bar\"" ) )
}
foobar = true ;
reader . close ( ) ;
if ( line . contains ( "submodule \"a\"" ) )
assertTrue ( "The foo submodule should exist" , foo ) ;
a = true ;
assertFalse ( "The foo/bar submodule shouldn't exist" , foobar ) ;
assertTrue ( "The a submodule should exist" , a ) ;
} finally {
tempDb . close ( ) ;
remoteDb . close ( ) ;
}
}
reader . close ( ) ;
assertTrue ( "The foo submodule should exist" , foo ) ;
assertFalse ( "The foo/bar submodule shouldn't exist" , foobar ) ;
assertTrue ( "The a submodule should exist" , a ) ;
}
}
@Test
@Test