Skip to content

Commit 9e2af93

Browse files
committed
updates for D19
1 parent 3f48a36 commit 9e2af93

File tree

2 files changed

+71
-55
lines changed

2 files changed

+71
-55
lines changed

LabCodeRepoSetup/src/main/java/edu/wpi/rbe/LabCodeRepoSetupMain.java

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ public static void main(String[] args) throws Exception {
5555
ArrayList<String> repoDestBaseNames = teamAssignments.get("repoDestBaseNames");
5656
String teamDestBaseName = teamAssignments.get("teamDestBaseName").get(0);
5757
numberOfTeams = Integer.parseInt(teamAssignments.get("numberOfTeams").get(0));
58-
58+
boolean useHW = true;
59+
try {
60+
useHW = Boolean.parseBoolean(teamAssignments.get("homework").get(0));
61+
} catch (Throwable t) {
62+
}
5963
if (args.length == 2) {
6064
String csvFileName = args[1];
6165
if (csvFileName.toLowerCase().endsWith(".csv")) {
@@ -112,8 +116,10 @@ public static void main(String[] args) throws Exception {
112116
System.out.println("Found " + projectDestBaseName);
113117

114118
Map<String, GHTeam> teams = dest.getTeams();
115-
PagedIterable<GHUser> teachingStaff = teams.get("TeachingStaff").listMembers();
116-
for (GHUser t : teachingStaff) {
119+
GHTeam teachTeam = teams.get("TeachingStaff");
120+
PagedIterable<GHUser> ts = teachTeam.listMembers();
121+
122+
for (GHUser t : ts) {
117123
System.out.println("Teacher: " + t.getLogin());
118124
}
119125
boolean deleteAll = false;
@@ -125,7 +131,7 @@ public static void main(String[] args) throws Exception {
125131
PagedIterable<GHUser> currentMembers = dest.listMembers();
126132
for (GHUser c : currentMembers) {
127133
boolean isTeach = false;
128-
for (GHUser t : teachingStaff) {
134+
for (GHUser t : teachTeam.listMembers()) {
129135
if (t.getLogin().contains(c.getLogin()) || t.getLogin().contains("madhephaestus")) {
130136
isTeach = true;
131137
break;
@@ -195,10 +201,6 @@ public static void main(String[] args) throws Exception {
195201
}
196202
}
197203

198-
for (GHUser t : teachingStaff) {
199-
if (!t.getLogin().contains("madhephaestus"))
200-
team.add(t, Role.MAINTAINER);
201-
}
202204
if (team.hasMember(github.getUser("madhephaestus")))
203205
team.remove(github.getUser("madhephaestus"));// FFS i dont want all these notifications...
204206
String repoFullName = repoDestBaseName + teamString;
@@ -225,23 +227,23 @@ public static void main(String[] args) throws Exception {
225227
cloneDirString = tmp.getAbsolutePath() + "/" + sourceRepo;
226228
cloneDir = new File(cloneDirString);
227229
if (cloneDir.exists()) {
228-
230+
229231
System.out.println(cloneDir.getAbsolutePath() + " Exists");
230232
List<String> commands = new ArrayList<String>();
231-
233+
232234
commands = new ArrayList<String>();
233235
commands.add("rm"); // command
234236
commands.add("-rf"); // command
235237
commands.add(cloneDir.getAbsolutePath()); // command
236238
run(commands, tmp);
237-
239+
238240
commands = new ArrayList<String>();
239241
commands.add("cp"); // command
240242
commands.add("-R"); // command
241-
commands.add(sourceRepo+"TMP"); // command
243+
commands.add(sourceRepo + "TMP"); // command
242244
commands.add(sourceRepo); // command
243245
run(commands, tmp);
244-
246+
245247
commands = new ArrayList<String>();
246248
commands.add("git"); // command
247249
commands.add("remote"); // command
@@ -264,19 +266,18 @@ public static void main(String[] args) throws Exception {
264266
commands.add("clone"); // command
265267
commands.add(sourceURL); // command
266268
run(commands, tmp);
267-
269+
268270
cloneDir = new File(tmp.getAbsolutePath() + "/" + sourceRepo);
269-
271+
270272
commands = new ArrayList<String>();
271273
commands.add("cp"); // command
272274
commands.add("-R"); // command
273275
commands.add(sourceRepo); // command
274-
commands.add(sourceRepo+"TMP"); // command
276+
commands.add(sourceRepo + "TMP"); // command
275277
run(commands, tmp);
276-
278+
277279
}
278280

279-
280281
}
281282
} catch (Exception e) {
282283
System.out.println("No source project found, leaving repos blank");
@@ -308,45 +309,43 @@ public static void main(String[] args) throws Exception {
308309
commands.add("config"); // command
309310
commands.add("-l"); // command
310311
run(commands, cloneDir);
311-
312-
File templateINO = new File(cloneDir.getAbsolutePath()+"/template.ino");
313-
if(templateINO.exists()) {
312+
313+
File templateINO = new File(cloneDir.getAbsolutePath() + "/template.ino");
314+
if (templateINO.exists()) {
314315
commands = new ArrayList<String>();
315316
commands.add("git"); // command
316317
commands.add("mv"); // command
317318
commands.add("template.ino"); // command
318-
commands.add(repoFullName+".ino"); // command
319+
commands.add(repoFullName + ".ino"); // command
319320
run(commands, cloneDir);
320-
321-
321+
322322
commands = new ArrayList<String>();
323323
commands.add("git"); // command
324324
commands.add("commit"); // command
325325
commands.add("-a"); // command
326326
commands.add("-m'Changing ino name'"); // command
327327
run(commands, cloneDir);
328328
}
329-
File doxyfile = new File(cloneDir.getAbsolutePath()+"/doxy.doxyfile");
330-
if(doxyfile.exists()) {
329+
File doxyfile = new File(cloneDir.getAbsolutePath() + "/doxy.doxyfile");
330+
if (doxyfile.exists()) {
331331
commands = new ArrayList<String>();
332332
commands.add("doxygen"); // command
333333
commands.add("doxy.doxyfile"); // command
334334
run(commands, cloneDir);
335-
335+
336336
commands = new ArrayList<String>();
337337
commands.add("git"); // command
338338
commands.add("add"); // command
339339
commands.add("doc/html/*"); // command
340340
run(commands, cloneDir);
341-
341+
342342
commands = new ArrayList<String>();
343343
commands.add("git"); // command
344344
commands.add("commit"); // command
345345
commands.add("-a"); // command
346346
commands.add("-mDoxygen"); // command
347347
run(commands, cloneDir);
348348
}
349-
350349

351350
// creating list of commands
352351
commands = new ArrayList<String>();
@@ -360,7 +359,7 @@ public static void main(String[] args) throws Exception {
360359
}
361360
}
362361
team.add(myTeamRepo, GHOrganization.Permission.ADMIN);
363-
362+
teachTeam.add(myTeamRepo, GHOrganization.Permission.ADMIN);
364363
}
365364

366365
System.out.println("All Students " + allStudents.size());
@@ -372,30 +371,29 @@ public static void main(String[] args) throws Exception {
372371
t.delete();
373372
}
374373
}
375-
Map<String, GHTeam> existingTeams = dest.getTeams();
376-
for (GHUser u : allStudents) {
377-
String hwTeam = "HomeworkTeam-" + u.getLogin();
378-
String hwRepoName = "HomeworkCode-" + u.getLogin();
379-
380-
GHRepository repositorie = dest.getRepository(hwRepoName);
381-
if (repositorie == null) {
382-
System.out.println("Creating Student Homework team " + hwRepoName);
383-
repositorie = createRepository(dest, hwRepoName, "Homework for " + u.getLogin());
384-
}
385-
GHTeam myTeam = existingTeams.get(hwTeam);
386-
if (myTeam == null) {
387-
myTeam = dest.createTeam(hwTeam, GHOrganization.Permission.ADMIN, repositorie);
374+
if (useHW) {
375+
Map<String, GHTeam> existingTeams = dest.getTeams();
376+
for (GHUser u : allStudents) {
377+
String hwTeam = "HomeworkTeam-" + u.getLogin();
378+
String hwRepoName = "HomeworkCode-" + u.getLogin();
379+
380+
GHRepository repositorie = dest.getRepository(hwRepoName);
381+
if (repositorie == null) {
382+
System.out.println("Creating Student Homework team " + hwRepoName);
383+
repositorie = createRepository(dest, hwRepoName, "Homework for " + u.getLogin());
384+
}
385+
GHTeam myTeam = existingTeams.get(hwTeam);
386+
if (myTeam == null) {
387+
myTeam = dest.createTeam(hwTeam, GHOrganization.Permission.ADMIN, repositorie);
388388

389-
}
390-
try {
391-
myTeam.add(u, Role.MAINTAINER);
392-
} catch (Exception ex) {
393-
System.out.println("Inviting " + u.getLogin() + " to " + hwTeam);
394-
}
395-
myTeam.add(repositorie, GHOrganization.Permission.ADMIN);
396-
for (GHUser t : teachingStaff) {
397-
if (!t.getLogin().contains("madhephaestus"))
398-
myTeam.add(t, Role.MAINTAINER);
389+
}
390+
try {
391+
myTeam.add(u, Role.MAINTAINER);
392+
} catch (Exception ex) {
393+
System.out.println("Inviting " + u.getLogin() + " to " + hwTeam);
394+
}
395+
myTeam.add(repositorie, GHOrganization.Permission.ADMIN);
396+
teachTeam.add(repositorie, GHOrganization.Permission.ADMIN);
399397
}
400398
}
401399
}
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
{
22
"deleteall":["false"],
3+
"homework":["false"],
34
"projectName":["RBE200x-lab"],
45
"repoDestBaseNames":["RBE2002Code"],
56
"teamDestBaseName":["RBE200xTeam"],
6-
"numberOfTeams":["14"],
7-
"RBE2002Code":["WPIRoboticsEngineering","RBE2002_template"]
7+
"numberOfTeams":["20"],
8+
"RBE2002Code":["WPIRoboticsEngineering","RBE2002_template"],
9+
"01":["dhMcHorney","ultimatejimjam","asefiyaoui"],
10+
"02":["TGSaddler","LukeTrujillo","WardBenjamin"],
11+
"03":["burningombre","jtgrotz","maggiearaque"],
12+
"04":["lhatfield15","Joshu-ahoy","ntaurich"],
13+
"05":["mtcharter","conkrr"],
14+
"06":["jcybul","SabLiu","mariasharman137"],
15+
"07":["markhogan1001","mjlaks"],
16+
"08":["Htrom14"],
17+
"09":["Zacoulou","amalik3099","pelund"],
18+
"10":["cbennet","manjushachava1","T-Reiser"],
19+
"11":["TheGreencoat","cmonyenokwe","pheobeyeung"],
20+
"12":["crayhj"],
21+
"13":["17craigiec","zseker","nastallings"],
22+
"14":["ishchan2","julia-dag"],
23+
"15":["atkneedler","lcreid1","jwestlake1"],
24+
"19":["clbesch","emmettmccann","trschaeffer"],
25+
"20":["madhephaestus","cbp952","Max5254"]
826
}

0 commit comments

Comments
 (0)