Skip to content

Commit

Permalink
Merge 6ad6df2 into fad8694
Browse files Browse the repository at this point in the history
  • Loading branch information
timgates42 committed Dec 3, 2019
2 parents fad8694 + 6ad6df2 commit 9bb6eec
Showing 1 changed file with 38 additions and 19 deletions.
57 changes: 38 additions & 19 deletions app/meticulous/_process.py
Expand Up @@ -71,7 +71,7 @@ def run_invocation(target):
"remove a repository": remove_repo_selection,
"add a new repository": add_new_repo,
"prepare a change": prepare_a_change,
"prepare an issue": prepare_an_issue,
"prepare a pr/issue": prepare_a_pr_or_issue,
}
handler = make_choice(lookup)
if handler is None:
Expand Down Expand Up @@ -108,38 +108,57 @@ def prepare_a_change(target): # pylint: disable=unused-argument
add_change_for_repo(repodir)


def prepare_an_issue(target): # pylint: disable=unused-argument
def prepare_a_pr_or_issue(target): # pylint: disable=unused-argument
"""
Select an available repository to prepare a change
"""
reponame, reposave = pick_repo_save()
while True:
repodir = reposave["repodir"]
repodirpath = Path(repodir)
issue_template = Path(".github") / "ISSUE_TEMPLATE"
has_issue_template = (repodirpath / issue_template).is_dir()
print(
f"{reponame} {'HAS' if has_issue_template else 'does not have'}"
f" an issue template"
)
contrib_guide = Path("CONTRIBUTING.md")
has_contrib_guide = (repodirpath / contrib_guide).is_file()
print(
f"{reponame} {'HAS' if has_contrib_guide else 'does not have'}"
f" a contributing guide"
)
choices = {}
if has_issue_template:
choices["show issue template"] = (show_path, issue_template)
if has_contrib_guide:
choices["show contribution guide"] = (show_path, contrib_guide)
choices = get_pr_or_issue_choices(reponame, repodirpath)
option = make_choice(choices)
if option is None:
return
handler, context = option
handler(reponame, reposave, context)


def get_pr_or_issue_choices(reponame, repodirpath):
"""
Work out the choices menu for pr/issue
"""
issue_template = Path(".github") / "ISSUE_TEMPLATE"
pr_template = Path(".github") / "pull_request_template.md"
contrib_guide = Path("CONTRIBUTING.md")
issue = Path("__issue__.txt")
prpath = Path("__pr__.txt")
choices = {}
for path in (issue_template, pr_template, contrib_guide, issue, prpath):
has_path = (repodirpath / path).exists()
print(f"{reponame} {'HAS' if has_path else 'does not have'}" f" {path}")
if has_path:
choices[f"show {path}"] = (show_path, path)
choices["make a full issue"] = (make_issue, True)
choices["make a short issue"] = (make_issue, False)
has_issue = (repodirpath / issue).exists()
if has_issue:
choices["submit issue"] = (submit_issue, None)
return choices


def make_issue(reponame, reposave, is_full): # pylint: disable=unused-argument
"""
Prepare an issue template file
"""


def submit_issue(reponame, reposave, ctxt): # pylint: disable=unused-argument
"""
Push up an issue
"""


def show_path(reponame, reposave, path): # pylint: disable=unused-argument
"""
Display the issue template directory
Expand Down

0 comments on commit 9bb6eec

Please sign in to comment.