|
|
@@ -478,6 +478,40 @@ def main():
|
|
|
and question.get("show_body") is True,
|
|
|
"answered question shows body + selected answer")
|
|
|
|
|
|
+ print("== B5: compare-changes SSH -> HTTPS ==")
|
|
|
+ def diff_url_for_project(git_url, suffix):
|
|
|
+ state = slot_public(auth, "/projects", "projects")
|
|
|
+ act(auth, state["create"], {"name": "diff-%s" % suffix, "git_url": git_url})
|
|
|
+ project_id = int([p["id"] for p in slot_public(auth, "/projects", "projects")["projects"]
|
|
|
+ if p["name"] == "diff-%s" % suffix][0])
|
|
|
+ conn = db()
|
|
|
+ conn.execute("insert into tasks (project_id, title, status, task_branch,"
|
|
|
+ " branch_from, created_at) values (?, ?, 'working', 'feature/x',"
|
|
|
+ " 'main', strftime('%s','now'))", (project_id, "Diff %s" % suffix))
|
|
|
+ conn.commit()
|
|
|
+ task_id = conn.execute("select max(id) from tasks").fetchone()[0]
|
|
|
+ conn.execute("insert into sessions (task_id, saddle_id, started_at, ended_at,"
|
|
|
+ " outcome) values (?, ?, strftime('%s','now'), strftime('%s','now'),"
|
|
|
+ " 'done')", (task_id, fake_id))
|
|
|
+ conn.commit()
|
|
|
+ session = conn.execute("select max(id) from sessions").fetchone()[0]
|
|
|
+ conn.close()
|
|
|
+ saddle_api("POST", "/api/saddle/%d/update" % fake_id, fake_token,
|
|
|
+ {"type": "block", "session_id": session, "data": {
|
|
|
+ "question": "Review the diff", "type": "review"}})
|
|
|
+ return task_state(auth, task_id).get("review_diff_url") or ""
|
|
|
+
|
|
|
+ check(diff_url_for_project("ssh://fabrica.unitatem.net:222/clanker/clanker-saddle.git",
|
|
|
+ "fabrica")
|
|
|
+ == "https://fabrica.unitatem.net/clanker/clanker-saddle/compare/main...feature/x",
|
|
|
+ "ssh://git@host:port/owner/repo.git translates (port dropped)")
|
|
|
+ check(diff_url_for_project("git@github.com:acme/widgets.git", "scp")
|
|
|
+ == "https://github.com/acme/widgets/compare/main...feature/x",
|
|
|
+ "git@host:owner/repo.git translates to the browse host")
|
|
|
+ check(diff_url_for_project("https://example.com/plain/repo", "plain")
|
|
|
+ == "https://example.com/plain/repo/compare/main...feature/x",
|
|
|
+ "HTTPS URLs pass through unchanged")
|
|
|
+
|
|
|
print("== feature 5: rules ==")
|
|
|
rules_state = slot_public(auth, "/rules", "rules")
|
|
|
for name, body in [
|