@@ -55,55 +55,58 @@ public static void main(String[] args) throws Exception {
5555 }
5656 System .out .println ("Found " + projectDestBaseName );
5757
58-
5958 for (int x = 0 ; x < repoDestBaseNames .size (); x ++) {
6059 String repoDestBaseName = repoDestBaseNames .get (x );
6160 for (int i = 1 ; i <= numberOfTeams ; i ++) {
62- String teamString = i > 9 ? "" + i : "0" + i ;
61+ try {
62+ String teamString = i > 9 ? "" + i : "0" + i ;
6363
64- String repoFullName = repoDestBaseName + teamString ;
65- File tmp = new File (System .getProperty ("java.io.tmpdir" ) + "/gittmp/" );
66- if (!tmp .exists ()) {
67- tmp .mkdirs ();
68- }
69- tmp .deleteOnExit ();
70- String cloneDirString = tmp .getAbsolutePath () + "/" ;
71- File cloneDir = new File (cloneDirString );
72- File myDir = new File (cloneDirString +repoFullName );
73- if (!myDir .exists ()) {
74- System .out .println ("Cloning " +repoFullName +" to " +cloneDirString );
64+ String repoFullName = repoDestBaseName + teamString ;
65+ File tmp = new File (System .getProperty ("java.io.tmpdir" ) + "/gittmp/" );
66+ if (!tmp .exists ()) {
67+ tmp .mkdirs ();
68+ }
69+ tmp .deleteOnExit ();
70+ String cloneDirString = tmp .getAbsolutePath () + "/" ;
71+ File cloneDir = new File (cloneDirString );
72+ File myDir = new File (cloneDirString + repoFullName );
73+ if (!myDir .exists ()) {
74+ System .out .println ("Cloning " + repoFullName + " to " + cloneDirString );
75+ List <String > commands = new ArrayList <String >();
76+ commands .add ("git" ); // command
77+ commands .add ("clone" ); // command
78+ commands .
add (
"[email protected] :" +
projectDestBaseName +
"/" +
repoFullName +
".git" );
// command 79+ LabCodeRepoSetupMain .run (commands , cloneDir );
80+ myDir = new File (cloneDirString + repoFullName );
81+ } else {
82+ System .out .println (myDir .getName () + " exists" );
83+ List <String > commands = new ArrayList <String >();
84+ commands = new ArrayList <String >();
85+ commands .add ("git" ); // command
86+ commands .add ("pull" ); // command
87+ commands .add ("origin" ); // command
88+ commands .add ("master" ); // command
89+ LabCodeRepoSetupMain .run (commands , myDir );
90+ }
91+ String sourceProj = teamAssignments .get (repoDestBaseName ).get (0 );
92+ String sourceRepo = teamAssignments .get (repoDestBaseName ).get (1 );
7593 List <String > commands = new ArrayList <String >();
7694 commands .add ("git" ); // command
77- commands .add ("clone" ); // command
78- commands .
add (
"[email protected] :" +
projectDestBaseName +
"/" +
repoFullName +
".git" );
// command 79- LabCodeRepoSetupMain .run (commands , cloneDir );
80- myDir = new File (cloneDirString +repoFullName );
81- }else {
82- System .out .println (myDir .getName ()+" exists" );
83- List <String > commands = new ArrayList <String >();
95+ commands .add ("pull" ); // command
96+ commands .
add (
"[email protected] :" +
sourceProj +
"/" +
sourceRepo +
".git" );
// command 97+ commands .add ("master" ); // command
98+ LabCodeRepoSetupMain .run (commands , myDir );
99+
84100 commands = new ArrayList <String >();
85101 commands .add ("git" ); // command
86- commands .add ("pull " ); // command
102+ commands .add ("push " ); // command
87103 commands .add ("origin" ); // command
88104 commands .add ("master" ); // command
89105 LabCodeRepoSetupMain .run (commands , myDir );
106+ } catch (Throwable t ) {
107+ t .printStackTrace ();
90108 }
91- String sourceProj = teamAssignments .get (repoDestBaseName ).get (0 );
92- String sourceRepo = teamAssignments .get (repoDestBaseName ).get (1 );
93- List <String > commands = new ArrayList <String >();
94- commands .add ("git" ); // command
95- commands .add ("pull" ); // command
96- commands .
add (
"[email protected] :" +
sourceProj +
"/" +
sourceRepo +
".git" );
// command 97- commands .add ("master" ); // command
98- LabCodeRepoSetupMain .run (commands , myDir );
99-
100- commands = new ArrayList <String >();
101- commands .add ("git" ); // command
102- commands .add ("push" ); // command
103- commands .add ("origin" ); // command
104- commands .add ("master" ); // command
105- LabCodeRepoSetupMain .run (commands , myDir );
106-
109+
107110 }
108111 }
109112
0 commit comments