-
Notifications
You must be signed in to change notification settings - Fork 4
/
make-indiv-draft
executable file
·96 lines (79 loc) · 2.78 KB
/
make-indiv-draft
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! /usr/bin/env python3
"""
Create an IETF WG repository for an I-D
"""
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('--doc', '-d', metavar='DOCNAME', required=True)
parser.add_argument('--asis', '-a', action='store_true',
help="Don't try to standardize the name")
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:])
repo_utils.check_i_d_tools_are_installed()
DOCNAME = args.doc
ASIS = args.asis
# Login
G, USER = UTILS.gh_login(args)
# For individual draft, the WGNAME is the USER name
WGNAME = USER
EDITORS = [USER]
# Fix doc name: remove draft- ietf- $WGNAME- from front
if not ASIS:
while True:
for prefix in ('draft-', 'ietf-', WGNAME+'-'):
found = False
if DOCNAME.startswith(prefix):
DOCNAME = DOCNAME[len(prefix):]
found = True
if not found:
break
if len(DOCNAME) == 0:
raise SystemExit("Docname is all prefixes!")
# Verify user names
if not UTILS.verify_users(G, EDITORS):
raise SystemExit("Missing GH accounts")
# See if organization exists.
WGNAME = UTILS.fix_wg_name(WGNAME)
DOC = "draft-" + WGNAME + "-" + DOCNAME
ORG = USER
# if not UTILS.org_exists(G, ORG):
# raise SystemExit("Organization not found; try make-ietf-wg")
# o = G.get_organization(ORG)
# Create an editors team and populate it
# editors = o.create_team(DOC, privacy='closed')
# editors.add_membership(G.get_user(USER))
# done = [ USER ]
# for e in EDITORS:
# if e not in done:
# editors.add_membership(G.get_user(e))
# done += [ e ]
# Add the "owners" people?
if os.path.lexists(DOC):
sys.exit("Error: destination path '{}' already exists.".format(DOC))
# Create repository draft-$WGNAME-$DOCNAME
u = G.get_user()
repo = u.create_repo(DOC,
description="Repository for " + DOC + " draft",
)
# Remove pre-populated labels, add ours.
for label in repo.get_labels():
label.delete()
repo.create_label("editorial", "41d366")
repo.create_label("design", "1d76db")
repo.create_label("parked", "f9d0c4")
initial_files = {}
initial_files["CONTRIBUTING.md"] = repo_utils.contributing(wgname=WGNAME)
FULL_DRAFT_NAME = "draft-%(WGNAME)s-%(DOCNAME)s" % vars()
initial_files[FULL_DRAFT_NAME + ".md"] = repo_utils.initial_draft(
full_draft_name=FULL_DRAFT_NAME, docname=DOCNAME)
repo_utils.clone_and_create_initial_commit(
user=WGNAME, repo=DOC, default_branch=args.default_branch,
initial_files=initial_files)
repo_utils.setup_i_d_template()