fix: reconcile Gitea Ralph status labels
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
"number": 5,
|
"number": 5,
|
||||||
"url": "https://git.d-popov.com/popov/neuron-tai/issues/5",
|
"url": "https://git.d-popov.com/popov/neuron-tai/issues/5",
|
||||||
"state": "open",
|
"state": "open",
|
||||||
"status": "in-progress"
|
"status": "ready"
|
||||||
},
|
},
|
||||||
"DGR-022": {
|
"DGR-022": {
|
||||||
"number": 6,
|
"number": 6,
|
||||||
|
|||||||
@@ -8,5 +8,9 @@ cd "$ROOT"
|
|||||||
python3 scripts/ralph_gitea_sync.py sync
|
python3 scripts/ralph_gitea_sync.py sync
|
||||||
ralph_status=0
|
ralph_status=0
|
||||||
"$@" || ralph_status=$?
|
"$@" || ralph_status=$?
|
||||||
|
if [ "$ralph_status" -eq 0 ]; then
|
||||||
python3 scripts/ralph_gitea_sync.py sync
|
python3 scripts/ralph_gitea_sync.py sync
|
||||||
|
else
|
||||||
|
python3 scripts/ralph_gitea_sync.py sync --reset-in-progress
|
||||||
|
fi
|
||||||
exit "$ralph_status"
|
exit "$ralph_status"
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ def main() -> int:
|
|||||||
parser.add_argument("--feature-dir", type=Path, default=DEFAULT_FEATURE)
|
parser.add_argument("--feature-dir", type=Path, default=DEFAULT_FEATURE)
|
||||||
parser.add_argument("--repo-url", default="https://git.d-popov.com/popov/neuron-tai")
|
parser.add_argument("--repo-url", default="https://git.d-popov.com/popov/neuron-tai")
|
||||||
parser.add_argument("--dry-run", action="store_true")
|
parser.add_argument("--dry-run", action="store_true")
|
||||||
|
parser.add_argument("--reset-in-progress", action="store_true", help="Do not claim a next story after a failed Ralph start")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
feature = args.feature_dir.resolve()
|
feature = args.feature_dir.resolve()
|
||||||
@@ -167,7 +168,7 @@ def main() -> int:
|
|||||||
milestones[title] = {"id": -len(milestones), "title": title}
|
milestones[title] = {"id": -len(milestones), "title": title}
|
||||||
|
|
||||||
passed = {s["id"] for s in stories if s.get("passes")}
|
passed = {s["id"] for s in stories if s.get("passes")}
|
||||||
next_story = next(
|
next_story = None if args.reset_in_progress else next(
|
||||||
(
|
(
|
||||||
s
|
s
|
||||||
for s in stories
|
for s in stories
|
||||||
@@ -194,6 +195,9 @@ def main() -> int:
|
|||||||
else:
|
else:
|
||||||
issue = gitea.request("PATCH", f"/issues/{issue['number']}", payload)
|
issue = gitea.request("PATCH", f"/issues/{issue['number']}", payload)
|
||||||
print(f"reconciled {sid} #{issue.get('number')} {desired_status}")
|
print(f"reconciled {sid} #{issue.get('number')} {desired_status}")
|
||||||
|
# Gitea's issue PATCH does not reliably replace labels; use the
|
||||||
|
# dedicated endpoint so stale status:in-progress labels are removed.
|
||||||
|
gitea.request("PUT", f"/issues/{issue['number']}/labels", {"labels": label_ids})
|
||||||
mapping[sid] = {"number": issue.get("number"), "url": issue.get("html_url"), "state": "closed" if story.get("passes") else "open", "status": desired_status}
|
mapping[sid] = {"number": issue.get("number"), "url": issue.get("html_url"), "state": "closed" if story.get("passes") else "open", "status": desired_status}
|
||||||
|
|
||||||
if not args.dry_run:
|
if not args.dry_run:
|
||||||
|
|||||||
Reference in New Issue
Block a user