@@ -157,50 +157,7 @@ public static void main(String[] args) throws Exception {
157157 File cloneDir = null ;
158158 String cloneDirString = "" ;
159159 String sourceURL = null ;// "https://github.com/" + sourceProj + "/" + sourceRepo + ".git";
160- try {
161- String sourceProj = teamAssignments .get (repoDestBaseName ).get (0 );
162- String sourceRepo = teamAssignments .get (repoDestBaseName ).get (1 );
163- if (sourceProj != null && sourceRepo != null ) {
164- sourceURL = "git@github.com:" + sourceProj + "/" + sourceRepo + ".git" ;
165-
166- File tmp = new File (System .getProperty ("java.io.tmpdir" ) + "/gittmp/" );
167- if (!tmp .exists ()) {
168- tmp .mkdirs ();
169- }
170- tmp .deleteOnExit ();
171- cloneDirString = tmp .getAbsolutePath () + "/" + sourceRepo ;
172- cloneDir = new File (cloneDirString );
173- if (cloneDir .exists ()) {
174- System .out .println (cloneDir .getAbsolutePath () + " Exists" );
175- List <String > commands = new ArrayList <String >();
176- commands .add ("git" ); // command
177- commands .add ("remote" ); // command
178- commands .add ("set-url" ); // command
179- commands .add ("origin" ); // command
180- commands .add (sourceURL ); // command
181- run (commands , cloneDir );
182- commands = new ArrayList <String >();
183- commands .add ("git" ); // command
184- commands .add ("pull" ); // command
185- commands .add ("origin" ); // command
186- commands .add ("master" ); // command
187- run (commands , cloneDir );
188- } else {
189- System .out .println ("Cloning " + sourceURL );
190- System .out .println ("Cloning to " + sourceRepo );
191- // creating list of commands
192- List <String > commands = new ArrayList <String >();
193- commands .add ("git" ); // command
194- commands .add ("clone" ); // command
195- commands .add (sourceURL ); // command
196- run (commands , tmp );
197160
198- cloneDir = new File (tmp .getAbsolutePath () + "/" + sourceRepo );
199- }
200- }
201- } catch (Exception e ) {
202- System .out .println ("No source project found, leaving repos blank" );
203- }
204161 for (int i = 1 ; i <= numberOfTeams ; i ++) {
205162 String teamString = i > 9 ? "" + i : "0" + i ;
206163 GHTeam team = teams .get (teamDestBaseName + teamString );
@@ -246,13 +203,84 @@ public static void main(String[] args) throws Exception {
246203 team .remove (github .getUser ("madhephaestus" ));// FFS i dont want all these notifications...
247204 String repoFullName = repoDestBaseName + teamString ;
248205 GHRepository myTeamRepo = dest .getRepository (repoFullName );
206+
249207 if (myTeamRepo == null ) {
250208 System .out .println ("Missing Repo, creating " + repoFullName );
251209 myTeamRepo = createRepository (dest , repoFullName , "RBE Class team repo for team " + teamString );
252210 while (dest .getRepository (repoFullName ) == null ) {
253211 System .out .println ("Waiting for the creation of " + repoFullName );
254212 Thread .sleep (1000 );
255213 }
214+ try {
215+ String sourceProj = teamAssignments .get (repoDestBaseName ).get (0 );
216+ String sourceRepo = teamAssignments .get (repoDestBaseName ).get (1 );
217+ if (sourceProj != null && sourceRepo != null ) {
218+ sourceURL = "git@github.com:" + sourceProj + "/" + sourceRepo + ".git" ;
219+
220+ File tmp = new File (System .getProperty ("java.io.tmpdir" ) + "/gittmp/" );
221+ if (!tmp .exists ()) {
222+ tmp .mkdirs ();
223+ }
224+ tmp .deleteOnExit ();
225+ cloneDirString = tmp .getAbsolutePath () + "/" + sourceRepo ;
226+ cloneDir = new File (cloneDirString );
227+ if (cloneDir .exists ()) {
228+
229+ System .out .println (cloneDir .getAbsolutePath () + " Exists" );
230+ List <String > commands = new ArrayList <String >();
231+
232+ commands = new ArrayList <String >();
233+ commands .add ("rm" ); // command
234+ commands .add ("-rf" ); // command
235+ commands .add (cloneDir .getAbsolutePath ()); // command
236+ run (commands , tmp );
237+
238+ commands = new ArrayList <String >();
239+ commands .add ("cp" ); // command
240+ commands .add ("-R" ); // command
241+ commands .add (sourceRepo +"TMP" ); // command
242+ commands .add (sourceRepo ); // command
243+ run (commands , tmp );
244+
245+ commands = new ArrayList <String >();
246+ commands .add ("git" ); // command
247+ commands .add ("remote" ); // command
248+ commands .add ("set-url" ); // command
249+ commands .add ("origin" ); // command
250+ commands .add (sourceURL ); // command
251+ run (commands , cloneDir );
252+ commands = new ArrayList <String >();
253+ commands .add ("git" ); // command
254+ commands .add ("pull" ); // command
255+ commands .add ("origin" ); // command
256+ commands .add ("master" ); // command
257+ run (commands , cloneDir );
258+ } else {
259+ System .out .println ("Cloning " + sourceURL );
260+ System .out .println ("Cloning to " + sourceRepo );
261+ // creating list of commands
262+ List <String > commands = new ArrayList <String >();
263+ commands .add ("git" ); // command
264+ commands .add ("clone" ); // command
265+ commands .add (sourceURL ); // command
266+ run (commands , tmp );
267+
268+ cloneDir = new File (tmp .getAbsolutePath () + "/" + sourceRepo );
269+
270+ commands = new ArrayList <String >();
271+ commands .add ("cp" ); // command
272+ commands .add ("-R" ); // command
273+ commands .add (sourceRepo ); // command
274+ commands .add (sourceRepo +"TMP" ); // command
275+ run (commands , tmp );
276+
277+ }
278+
279+
280+ }
281+ } catch (Exception e ) {
282+ System .out .println ("No source project found, leaving repos blank" );
283+ }
256284 if (cloneDir != null && cloneDir .exists ()) {
257285 // creating list of commands
258286 List <String > commands = new ArrayList <String >();
@@ -280,6 +308,25 @@ public static void main(String[] args) throws Exception {
280308 commands .add ("config" ); // command
281309 commands .add ("-l" ); // command
282310 run (commands , cloneDir );
311+
312+ File templateINO = new File (cloneDir .getAbsolutePath ()+"/template.ino" );
313+ if (templateINO .exists ()) {
314+ commands = new ArrayList <String >();
315+ commands .add ("git" ); // command
316+ commands .add ("mv" ); // command
317+ commands .add ("template.ino" ); // command
318+ commands .add (repoFullName +".ino" ); // command
319+ run (commands , cloneDir );
320+
321+
322+ commands = new ArrayList <String >();
323+ commands .add ("git" ); // command
324+ commands .add ("commit" ); // command
325+ commands .add ("-a" ); // command
326+ commands .add ("-m'Changing ino name'" ); // command
327+ run (commands , cloneDir );
328+ }
329+
283330
284331 // creating list of commands
285332 commands = new ArrayList <String >();
0 commit comments