Commit e8c79e2d authored by Cyril Matthey-Doret's avatar Cyril Matthey-Doret
Browse files

add dry-run option to send_feedback.py

parent e7b7cbd3
Pipeline #387544 passed with stage
in 4 minutes and 8 seconds
......@@ -80,7 +80,12 @@ def fill_template(content: Dict[str, str], template: str) -> str:
"The id column should match a gitlab project ID from the JSON input.",
default=None,
)
def main(forks, feedback, token, template):
@click.option(
"--dry-run",
is_flag=True,
help="Print feedback to stdout instead of opening issues"
)
def main(forks, feedback, token, template, dry_run):
"""
Send feedback to repositories in input JSON by opening issues.
"""
......@@ -101,8 +106,8 @@ def main(forks, feedback, token, template):
feedback_template = open(template).read()
else:
feedback_template = FEEDBACK_TEMPLATE
for fork in forks:
for fork in forks:
# Get basic fields from repo metadata in json
base, group, repo = parse_repo_url(fork["url"])
members = "\n".join([f"* {member['name']}" for member in fork["members"]])
......@@ -127,11 +132,15 @@ def main(forks, feedback, token, template):
# Replace fields in the template by their value for the current fork
description = fill_template(fill_data, feedback_template)
# Create issue
requests.post(
f"{base}/api/v4/projects/{fork['id']}/issues?confidential=true&title=Feedback",
headers=header,
data={"description": description},
)
if dry_run:
print(fork)
print(description)
else:
requests.post(
f"{base}/api/v4/projects/{fork['id']}/issues?confidential=true&title=Feedback",
headers=header,
data={"description": description},
)
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment