@@ -62,6 +62,15 @@ def create(token, name, systems, org, private):
6262def update (name , token , org ):
6363 run_update (name = name , token = token , org = org )
6464
65+
66+ @cli .command ()
67+ @click .option ('--name' , prompt = 'Name' , help = '' )
68+ @click .option ('--org' , help = 'GitHub Organization' , default = False )
69+ @click .option ('--token' , prompt = 'GitHub API Token' , help = '' )
70+ def upgrade (name , token , org ):
71+ run_upgrade (name = name , token = token , org = org )
72+
73+
6574@cli .command ()
6675@click .option ('--name' , prompt = 'Name' , help = '' )
6776@click .option ('--org' , help = 'GitHub Organization' , default = False )
@@ -71,6 +80,38 @@ def automate(name, token, org, key):
7180 run_automate (name = name , token = token , org = org , key = key )
7281
7382
83+ def run_upgrade (name , token , org ):
84+ click .echo ("Upgrading..." )
85+
86+ repo = get_repo (token = token , name = name , org = org )
87+ files = [file .path for file in repo .get_dir_contents ("/" , ref = "gh-pages" )]
88+ head_sha = repo .get_git_ref ("heads/gh-pages" ).object .sha
89+
90+ # add all the template files to the gh-pages branch
91+ for template in tqdm (TEMPLATES , desc = "Updating template files" ):
92+ with open (os .path .join (ROOT , "template" , template ), "r" ) as f :
93+ content = f .read ()
94+ if template in files :
95+ template_sha = repo .get_file_contents (
96+ path = "/" + template ,
97+ ref = head_sha ,
98+ ).sha
99+ repo .update_file (
100+ path = "/" + template ,
101+ sha = template_sha ,
102+ message = "upgrade" ,
103+ content = content ,
104+ branch = "gh-pages"
105+ )
106+ else :
107+ repo .create_file (
108+ path = "/" + template ,
109+ message = "upgrade" ,
110+ content = content ,
111+ branch = "gh-pages"
112+ )
113+
114+
74115def run_update (name , token , org ):
75116 click .echo ("Generating.." )
76117 repo = get_repo (token = token , name = name , org = org )
0 commit comments