Skip to content

Commit 018d958

Browse files
authored
Create repos.js
1 parent efa16b1 commit 018d958

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

repos.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
2+
// create a repository object
3+
function createRepoObj(fullName, selBranch, pushAccess,
4+
branches, private, isFork, empty) {
5+
6+
return {
7+
fullName,
8+
selBranch,
9+
pushAccess,
10+
branches,
11+
private,
12+
isFork,
13+
empty
14+
}
15+
16+
}
17+
18+
19+
// modified repos
20+
21+
function addRepoToModRepos(repoObj) {
22+
23+
modifiedRepos[repoObj.fullName] = repoObj;
24+
25+
updateModReposLS();
26+
27+
}
28+
29+
function updateModRepoSelectedBranch(fullName, selBranch) {
30+
31+
modifiedRepos[fullName].selBranch = selBranch;
32+
33+
updateModReposLS();
34+
35+
}
36+
37+
function updateModRepoPushAccess(fullName, pushAccess) {
38+
39+
modifiedRepos[fullName].pushAccess = pushAccess;
40+
41+
updateModReposLS();
42+
43+
}
44+
45+
function updateModRepoBranches(fullName, branches) {
46+
47+
modifiedRepos[fullName].branches = branches;
48+
49+
updateModReposLS();
50+
51+
}
52+
53+
function updateModRepoPrivateStatus(fullName, private) {
54+
55+
modifiedRepos[fullName].private = private;
56+
57+
updateModReposLS();
58+
59+
}
60+
61+
function updateModRepoEmptyStatus(fullName, empty) {
62+
63+
modifiedRepos[fullName].empty = empty;
64+
65+
updateModReposLS();
66+
67+
}
68+
69+
70+
71+
// fetch repo obj from git
72+
// and save to modified repos
73+
async function fetchRepoAndSaveToModRepos(treeLoc) {
74+
75+
// get repository from git
76+
const repo = await git.getRepo(treeLoc);
77+
78+
// if didn't encounter an error
79+
if (!repo.message) {
80+
81+
// create repo obj
82+
const repoObj = createRepoObj(repo.full_name, repo.default_branch, (item.permissions.push ?? false),
83+
null, repo.private, repo.fork, false);
84+
85+
// add repo to modified repos
86+
addRepoToModRepos(repoObj);
87+
88+
}
89+
90+
}

0 commit comments

Comments
 (0)