Skip to content

Commit 361c913

Browse files
committed
Making script robust to users not being members of the project yet.
1 parent fa97a1f commit 361c913

2 files changed

Lines changed: 23 additions & 12 deletions

File tree

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public static void main(String[] args) throws Exception {
110110
}
111111
System.out.println("Looking for source information for " + repoDestBaseName);
112112
File cloneDir = null;
113+
String cloneDirString = "";
113114
String sourceURL = null;// "https://github.com/" + sourceProj + "/" + sourceRepo + ".git";
114115
try {
115116
String sourceProj = teamAssignments.get(repoDestBaseName).get(0);
@@ -122,7 +123,8 @@ public static void main(String[] args) throws Exception {
122123
tmp.mkdirs();
123124
}
124125
tmp.deleteOnExit();
125-
cloneDir = new File(tmp.getAbsolutePath() + "/" + sourceRepo);
126+
cloneDirString=tmp.getAbsolutePath() + "/" + sourceRepo;
127+
cloneDir = new File(cloneDirString);
126128
if (cloneDir.exists()) {
127129
System.out.println(cloneDir.getAbsolutePath() + " Exists");
128130
List<String> commands = new ArrayList<String>();
@@ -152,9 +154,8 @@ public static void main(String[] args) throws Exception {
152154
}
153155
}
154156
} catch (Exception e) {
155-
e.printStackTrace();
157+
System.out.println("No source project found, leaving repos blank");
156158
}
157-
158159
for (int i = 1; i <= numberOfTeams; i++) {
159160
String teamString = i > 9 ? "" + i : "0" + i;
160161
GHTeam team = teams.get(teamDestBaseName + teamString);
@@ -168,21 +169,30 @@ public static void main(String[] args) throws Exception {
168169
System.out.println("ERROR: Team has no members in JSON " + teamString);
169170
continue;
170171
}
171-
172+
System.out.println("Team Found: " + team.getName());
172173
for (String member : members) {
174+
try {
173175
GHUser memberGH = github.getUser(member);
174176
if (memberGH == null) {
175177
System.out.println("ERROR GitHub user " + member + " does not exist");
176178
continue;
177179
}
178180
if (!team.hasMember(memberGH)) {
179-
System.out.println("Adding " + member + " to " + team.getName());
180-
team.add(memberGH, Role.MAINTAINER);
181+
try {
182+
team.add(memberGH, Role.MAINTAINER);
183+
System.out.println("Adding " + member + " to " + team.getName());
184+
}catch (Exception e) {
185+
System.out.println("Inviting " + member + " to " + team.getName());
186+
187+
}
181188
}
182189

183190
allStudents.add(memberGH);
191+
}catch(Exception ex) {
192+
System.err.println("\r\n\r\n ERROR "+member+" is not a valid GitHub username\r\n\r\n");
193+
}
184194
}
185-
System.out.println("Team Found: " + team.getName());
195+
186196
for (GHUser t : teachingStaff) {
187197
if (!t.getLogin().contains("madhephaestus"))
188198
team.add(t, Role.MAINTAINER);
@@ -235,8 +245,6 @@ public static void main(String[] args) throws Exception {
235245
commands.add("master"); // command
236246
run(commands, cloneDir);
237247

238-
} else {
239-
System.out.println("Directory missing " + cloneDir.getAbsolutePath());
240248
}
241249
}
242250
team.add(myTeamRepo, GHOrganization.Permission.ADMIN);
@@ -267,7 +275,11 @@ public static void main(String[] args) throws Exception {
267275
myTeam = dest.createTeam(hwTeam, GHOrganization.Permission.ADMIN, repositorie);
268276

269277
}
270-
myTeam.add(u, Role.MAINTAINER);
278+
try {
279+
myTeam.add(u, Role.MAINTAINER);
280+
}catch(Exception ex) {
281+
System.out.println("Inviting "+u+" to "+hwTeam);
282+
}
271283
myTeam.add(repositorie, GHOrganization.Permission.ADMIN);
272284
for (GHUser t : teachingStaff) {
273285
if (!t.getLogin().contains("madhephaestus"))

LabCodeRepoSetup/teamAssignments3002.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
"projectName":["RBE300X-Lab"],
44
"repoDestBaseNames":["RBE3002Code"],
55
"teamDestBaseName":["RBE300xTEAM"],
6-
"RBE3002Code":[""],
76
"numberOfTeams":["18"],
87
"01":["zzlotnick19", "AustinShalit", "Angelalalalalas"],
98
"02":["bpwagner19", "jonathanBerry", "erikasnow"],
109
"03":["smurfwars", "tessa4", "Parker-Parker"],
1110
"04":["animallover41097", "briggscalum", "tssheth"],
1211
"05":["mzhang5", "sanchezje", "katconroy57"],
1312
"06":["bpwagner19", "jonathanBerry", "erikasnow"],
14-
"07":["MingquanLiu", "@naomitharrison"],
13+
"07":["MingquanLiu", "naomitharrison"],
1514
"08":["ariannakan", "jaroy98", "Kdoje"],
1615
"09":["mcburd", "hpolshansky", "scasimir"],
1716
"10":["GabrielPRodriguez", "gyroth", "bmseibert"],

0 commit comments

Comments
 (0)