Skip to content

Commit eaac32f

Browse files
committed
create_rpm_git_repo: add --local flag
In some conditions we may not want to create the GH project: - when experimenting while not yet sure we will adopt the package - when an initial run of the script did create the project but not the local repo Signed-off-by: Yann Dirson <yann.dirson@vates.tech>
1 parent 12b2907 commit eaac32f

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

scripts/create_rpm_git_repo.py

+19-8
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88
def main():
99
parser = argparse.ArgumentParser(description='Creates a git repository in current directory for RPM spec file and sources')
1010
parser.add_argument('name', help='name of repository')
11+
parser.add_argument('--local',
12+
help='do not create github repository',
13+
action='store_true')
1114
parser.add_argument('token_file',
1215
help='file containing github authentication token',
1316
nargs='?',
1417
default=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'github.txt'))
1518
args = parser.parse_args()
1619

17-
# authenticate to Github
18-
token = open(args.token_file).read().strip()
19-
g = Github(token)
20+
if not args.local:
21+
# authenticate to Github
22+
token = open(args.token_file).read().strip()
23+
g = Github(token)
2024

21-
# create repository
22-
org = g.get_organization('xcp-ng-rpms')
23-
org.create_repo(args.name, "RPM sources for %s" % args.name)
25+
# create repository
26+
org = g.get_organization('xcp-ng-rpms')
27+
org.create_repo(args.name, "RPM sources for %s" % args.name)
2428

2529
# initial commit to master
2630
gitignore = """BUILD
@@ -39,7 +43,13 @@ def main():
3943
4044
Built RPMs and source RPMs are available on https://updates.xcp-ng.org.
4145
""" % args.name
42-
subprocess.check_call(['git', 'clone', 'https://github.com/xcp-ng-rpms/%s.git' % args.name])
46+
if args.local:
47+
subprocess.check_call(['git', 'init', args.name])
48+
subprocess.check_call(['git', '-C', args.name,
49+
'remote', 'add', 'origin',
50+
'https://github.com/xcp-ng-rpms/%s.git' % args.name])
51+
else:
52+
subprocess.check_call(['git', 'clone', 'https://github.com/xcp-ng-rpms/%s.git' % args.name])
4353
os.chdir(args.name)
4454
if "git@github.com" not in subprocess.check_output(
4555
['git', 'remote', 'get-url', '--push', 'origin'],
@@ -61,7 +71,8 @@ def main():
6171
subprocess.check_call(['git', 'lfs', 'track', '*.tbz'])
6272
subprocess.check_call(['git', 'add', '.gitattributes'])
6373
subprocess.check_call(['git', 'commit', '-s', '-m', 'Initial commit'])
64-
subprocess.check_call(['git', 'push'])
74+
if not args.local:
75+
subprocess.check_call(['git', 'push'])
6576

6677
if __name__ == "__main__":
6778
main()

0 commit comments

Comments
 (0)