-
Notifications
You must be signed in to change notification settings - Fork 4
/
make-ietf-wg
executable file
·77 lines (65 loc) · 2.37 KB
/
make-ietf-wg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /usr/bin/env python3
"""
Create an IETF WG organization and infrastructure
"""
import argparse
import os.path
import sys
import ietf_gh_utils as UTILS
import repo_utils
# Parse command line.
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--wg', '-w', required=True)
parser.add_argument('--chair', '-c', metavar='GH_ID', action='append', required=True,
help="(can be repeated, must be at least once)")
parser.add_argument('--ad', '-a', metavar='GH_ID', action='append', required=True,
help="(can be repeated, must be at least once)")
parser.add_argument('--default-branch', '-b', action='store', default='master',
help="Name the primary branch in the repository")
UTILS.add_gh_auth_arguments(parser)
args = parser.parse_args(sys.argv[1:])
WGNAME = args.wg
CHAIRS = args.chair
ADS = args.ad
# Login
G, USER = UTILS.gh_login(args)
# Verify user names
if not UTILS.verify_users(G, CHAIRS) or not UTILS.verify_users(G, ADS):
raise SystemExit("Missing GH accounts")
# See if organization exists.
WGNAME = UTILS.fix_wg_name(WGNAME)
ORG = 'ietf-wg-' + WGNAME
if not UTILS.org_exists(G, ORG):
text = open("creating-org.txt").read()
print(text % vars())
raise SystemExit
# Populate some organization meta-data
o = G.get_organization(ORG)
o.edit(
company="Internet Engineering Task Force",
description="The " + WGNAME + " working group",
email=WGNAME + "@ietf.org"
)
# Creates an "owners" team of the chairs and AD's
owners = o.create_team("owners", privacy='closed')
owners.add_membership(G.get_user(USER))
done = [USER]
for m in ADS + CHAIRS:
if m not in done:
owners.add_membership(G.get_user(m))
done += [m]
# Create a wg-materials repo, owned by the "owners" team.
REPO = "wg-materials"
if os.path.lexists(REPO):
sys.exit("Error: destination path '{}' already exists.".format(REPO))
o.create_repo(REPO,
description="Repository for meeting materials",
has_issues=True, # Probably the default, but this is funny
team_id=owners.id)
initial_files = {}
initial_files["CONTRIBUTING.md"] = repo_utils.contributing(wgname=WGNAME)
text = open("wg-readme.txt").read()
initial_files["README.md"] = text % vars()
repo_utils.clone_and_create_initial_commit(
user=ORG, repo=REPO, default_branch=args.default_branch,
initial_files=initial_files)