summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-07-01 14:32:38 -0700
committeriximeow <me@iximeow.net>2023-07-01 14:32:38 -0700
commitd6c7bd54efc0516fc561926279b36408b77fba33 (patch)
tree8798d5931a44989b442ccd6a5d54a4b21fff21d3
parentec5a274436bc8dda0b55d2c4da1411ff3c52434d (diff)
add og tags to commit summaries?
-rw-r--r--src/main.rs53
1 files changed, 35 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs
index f008a56..3e9f034 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -505,40 +505,57 @@ async fn handle_commit_status(Path(path): Path<(String, String, String)>, State(
let complete_time = run.complete_time.unwrap_or_else(crate::io::now_ms);
- let debug_info = run.state == RunState::Finished && run.build_result == Some(1) || run.state == RunState::Error;
-
- let repo_name: String = ctx.dbctx.conn.lock().unwrap()
- .query_row("select repo_name from repos where id=?1;", [repo_id], |row| row.get(0))
- .expect("can query");
-
- let deployed = false;
-
- let head = format!("<head><title>ci.butactuallyin.space - {}</title></head>", repo_name);
- let repo_html = format!("<a href=\"/{}\">{}</a>", &repo_name, &repo_name);
- let remote_commit_elem = format!("<a href=\"https://www.github.com/{}/commit/{}\">{}</a>", &remote_path, &sha, &sha);
- let status_elem = match run.state {
+ let (status_elem, status_desc) = match run.state {
RunState::Pending | RunState::Started => {
- "<span style='color:#660;'>pending</span>"
+ ("<span style='color:#660;'>pending</span>", "βŒ›in progress")
},
RunState::Finished => {
if let Some(build_result) = run.build_result {
if build_result == 0 {
- "<span style='color:green;'>pass</span>"
+ ("<span style='color:green;'>pass</span>", "βœ… passed")
} else {
- "<span style='color:red;'>failed</span>"
+ ("<span style='color:red;'>failed</span>", "❌ failed")
}
} else {
eprintln!("run {} for commit {} is missing a build result but is reportedly finished (old data)?", run.id, commit_id);
- "<span style='color:red;'>unreported</span>"
+ ("<span style='color:red;'>unreported</span>", "❔ missing status")
}
},
RunState::Error => {
- "<span style='color:red;'>error</span>"
+ ("<span style='color:red;'>error</span>", "🧯 error, uncompleted")
}
RunState::Invalid => {
- "<span style='color:red;'>(server error)</span>"
+ ("<span style='color:red;'>(server error)</span>", "dude even i don't know")
}
};
+ let debug_info = run.state == RunState::Finished && run.build_result == Some(1) || run.state == RunState::Error;
+
+ let repo_name: String = ctx.dbctx.conn.lock().unwrap()
+ .query_row("select repo_name from repos where id=?1;", [repo_id], |row| row.get(0))
+ .expect("can query");
+
+ let deployed = false;
+
+ let mut head = String::new();
+ head.push_str("<head>");
+ head.push_str(&format!("<title>ci.butactuallyin.space - {}</title>", repo_name));
+ let include_og_tags = true;
+ if include_og_tags {
+ head.push_str("\n");
+ head.push_str(&format!("<meta property=\"og:type\" content=\"website\">\n"));
+ head.push_str(&format!("<meta property=\"og:site_name\" content=\"ci.butactuallyin.space\">\n"));
+ head.push_str(&format!("<meta property=\"og:url\" content=\"/{}/{}/{}\"\n", &path.0, &path.1, &sha));
+ let build_og_description = format!("commit {} of {}/{}, {} after {}",
+ sha,
+ path.0, path.1,
+ status_desc,
+ display_run_time(&run)
+ );
+ head.push_str(&format!("<meta property=\"og:description\" content=\"{}\"\n>", build_og_description));
+ }
+ head.push_str("</head>\n");
+ let repo_html = format!("<a href=\"/{}\">{}</a>", &repo_name, &repo_name);
+ let remote_commit_elem = format!("<a href=\"https://www.github.com/{}/commit/{}\">{}</a>", &remote_path, &sha, &sha);
let mut artifacts_fragment = String::new();
let mut artifacts: Vec<ArtifactRecord> = ctx.dbctx.artifacts_for_run(run.id, None).unwrap()