@@ -55,5 +55,39 @@ def install():
55
55
add_to_pass (s , priv )
56
56
57
57
58
+ def clone (url , into ):
59
+ sh .rm ('-rf' , into )
60
+ sh .git .clone (url , into )
61
+ log .info ('Cloned' , url = url , into = into )
62
+
63
+
64
+ def prepare_repo (tmpl_url , into_repo = None ):
65
+ """Prepare the repository for flux."""
66
+ sh .mkdir ('-p' , './tmp' )
67
+ if not into_repo :
68
+ into_repo = f'git@{ E ("GITOPS_HOST" )} :{ E ("GITOPS_OWNER" )} /{ E ("GITOPS_REPO" )} '
69
+ di = './tmp/into.git'
70
+ clone (into_repo , di )
71
+
72
+ if tmpl_url .startswith ('gh:' ):
73
+ tmpl_url = f'https://github.com{ tmpl_url [3 :]} '
74
+ d_src = './tmp/tmpl.git'
75
+ clone (tmpl_url , d_src )
76
+
77
+ for r in ['README.md' , 'LICENSE' , 'CODE_OF_CONDUCT.md' , 'CONTRIBUTING.md' , '.git' ]:
78
+ sh .rm ('-rf' , d_src + '/' + r )
79
+
80
+ tar_command = sh .tar ('cf' , '-' , '.' , _cwd = d_src , _piped = True )
81
+ sh .tar ('xf' , '-' , '-C' , di , _in = tar_command )
82
+ log .info ('copied' , src = d_src , into = di )
83
+
84
+ with sh .pushd (d_src ):
85
+ breakpoint () # FIXME BREAKPOINT
86
+ sh .git ('add' , '.' )
87
+ sh .git ('commit' , '-am' , f'flux: initial commit\n \n { tmpl_url } \n ->\n { into_repo } ' )
88
+ sh .git ('push' )
89
+
90
+
58
91
class flux :
92
+ prepare_repo = prepare_repo
59
93
install = install
0 commit comments