Skip to content

Commit f326e24

Browse files
committed
feat: basic shell clone
with tests and collation
1 parent 658eecb commit f326e24

File tree

6 files changed

+100
-0
lines changed

6 files changed

+100
-0
lines changed

docs/DesignNotes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ Pytest has been choosen as the test too.
2828
CI/CD integration with the github actions
2929
----------------------------------------
3030

31+
Is it possible to detect if the ssh key is valid for the org?
32+
-------------------------------------------------------

pytest.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[pytest]
2+
markers =
3+
integration: slower tests on network

src/clone/shell_clone.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import sys
2+
import os
3+
4+
5+
def clone(git_url):
6+
clone_cmd = f"git clone {git_url}"
7+
8+
9+
def clone_list(nodes, to_folder):
10+
os.chdir(to_folder)
11+
for node in nodes:
12+
print(node["name"])
13+
clone(node["url"])

src/read_github_namespace/graph/fetch_org_repos.py

+9
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,12 @@ def fetch_org_repos(organization):
5252
result = client.execute(query, variable_values=params)
5353
print(result)
5454
return result
55+
56+
def collate(data):
57+
try:
58+
pass
59+
nodes = data["organization"]["repositories"]["nodes"]
60+
return nodes
61+
except Exception as err:
62+
print(f"Unexpected {err}")
63+
raise err

tests/test_collate_repos.py

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import pytest
2+
3+
from src.read_github_namespace.graph.fetch_org_repos import collate
4+
5+
6+
data = {"organization": {
7+
"repositories": {
8+
"pageInfo": {
9+
"endCursor": "Y3Vyc29yOnYyOpKkcnViec4FZeYV",
10+
"hasNextPage": False
11+
},
12+
"nodes": [
13+
{
14+
"name": ".github",
15+
"url": "https://github.com/kubernetes-client/.github"
16+
},
17+
{
18+
"name": "c",
19+
"url": "https://github.com/kubernetes-client/c"
20+
},
21+
{
22+
"name": "csharp",
23+
"url": "https://github.com/kubernetes-client/csharp"
24+
},
25+
{
26+
"name": "gen",
27+
"url": "https://github.com/kubernetes-client/gen"
28+
},
29+
{
30+
"name": "go",
31+
"url": "https://github.com/kubernetes-client/go"
32+
},
33+
{
34+
"name": "go-base",
35+
"url": "https://github.com/kubernetes-client/go-base"
36+
},
37+
{
38+
"name": "haskell",
39+
"url": "https://github.com/kubernetes-client/haskell"
40+
},
41+
{
42+
"name": "java",
43+
"url": "https://github.com/kubernetes-client/java"
44+
},
45+
{
46+
"name": "javascript",
47+
"url": "https://github.com/kubernetes-client/javascript"
48+
},
49+
{
50+
"name": "perl",
51+
"url": "https://github.com/kubernetes-client/perl"
52+
},
53+
{
54+
"name": "python",
55+
"url": "https://github.com/kubernetes-client/python"
56+
},
57+
{
58+
"name": "python-base",
59+
"url": "https://github.com/kubernetes-client/python-base"
60+
},
61+
{
62+
"name": "ruby",
63+
"url": "https://github.com/kubernetes-client/ruby"
64+
}
65+
]
66+
}
67+
}}
68+
69+
def test_collate():
70+
test_org = "kubernetes-client"
71+
collated = collate(data)
72+
assert len(collated) == len(data["organization"]["repositories"]["nodes"])

tests/test_int_fetch_org_repos.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from src.read_github_namespace.graph.fetch_org_repos import fetch_org_repos
44

5+
@pytest.mark.integration
56
def test_fetch():
67
try:
78
fetch_org_repos('kubernetes-client')

0 commit comments

Comments
 (0)