Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh

Commit

A pushed annotated tag is announced at the commit its own tag object names (#55): with 3c9af97b live, pushing the annotated v0.0.0-tagtest2 to flagon-io/automation-lab published no git.push at all. Right after a push the store neither logs a new tag's ref nor has it in its ref advertisement yet (minutes later both have it, with its ^{} line at main), so 3c9af97b took the tag as refused; that is also why cli-v0.3.7 under 4e63b3f7 fell back to its tag object. The push itself says where the tag leads: when a push that ended within what is read moves a tag, git_http reads its pack (g1t_scan Pack) and peels each pushed tag object, following a tag of a tag, to the commit its object line names (Pushed.peeled). pushed_to announces a tag at that commit unless the advertisement has the tag elsewhere; a tag the advertisement has at the hash pushed takes its ^{} line first; one not advertised yet with nothing peeled is left to the log check, as before 3c9af97b. Deploy: repos. Checked: cargo test -p g1t-repos (370; new: a tag and a tag of a tag peeled from a real pack, lightweight tags and branches left alone; a tag not yet advertised announced at its pack's commit); cargo check -p g1t-repos --target wasm32-unknown-unknown.

G1t-Session:
ses_01m4zbw69vethr4vmwsmcpwe3n
syntaqxcommitted Parent3c9af97Browse files
3 files+33−100/3 viewed
+0−0

Binary or large file; its contents are not shown.

+2−2
33993399 use super::*;
34003400
34013401 fn pushed(git_ref: String) -> git_http::Pushed {
3402− git_http::Pushed { git_ref, before: None, after: "abc".into() }
3402+ git_http::Pushed { git_ref, before: None, after: "abc".into(), peeled: None }
34033403 }
34043404
34053405 fn refs(announced: Vec<&git_http::Pushed>) -> Vec<&str> {
34393439 .unwrap();
34403440 PushDone {
34413441 repo,
3442− pushed: refs.iter().map(|git_ref| git_http::Pushed { git_ref: (*git_ref).into(), before: None, after: "abc".into() }).collect(),
3442+ pushed: refs.iter().map(|git_ref| git_http::Pushed { git_ref: (*git_ref).into(), before: None, after: "abc".into(), peeled: None }).collect(),
34433443 deleted: Vec::new(),
34443444 pack_bytes: 0,
34453445 actor: None,
+31−8
5959 }
6060 if let Some(refs) = advertised {
6161 let at = |name: &str| refs.iter().find(|(advertised, _)| advertised == name).map(|(_, hash)| hash.clone());
62− return Ok(match at(&pushed.git_ref) {
63− Some(hash) if hash == pushed.after => Some(at(&format!("{}^{{}}", pushed.git_ref)).unwrap_or(hash)),
64− // Not there, or left elsewhere: the store refused it.
65− _ => None,
66− });
62+ match at(&pushed.git_ref) {
63+ Some(hash) if hash == pushed.after => {
64+ return Ok(Some(at(&format!("{}^{{}}", pushed.git_ref)).or_else(|| pushed.peeled.clone()).unwrap_or(hash)));
65+ }
66+ // Left elsewhere: the store refused it.
67+ Some(_) => return Ok(None),
68+ // Not advertised yet, right after the push (v0.0.0-tagtest2):
69+ // the pack's own tag object says where it leads.
70+ None => {
71+ if let Some(commit) = &pushed.peeled {
72+ return Ok(Some(commit.clone()));
73+ }
74+ }
75+ }
76+ } else if let Some(commit) = &pushed.peeled {
77+ return Ok(Some(commit.clone()));
6778 }
6879 let Ok(head) = git.log(&pushed.git_ref, 1).await else {
6980 return Ok(Some(pushed.after.clone()));
332343 }
333344
334345 fn push(git_ref: &str, before: Option<&str>, after: &str) -> crate::git_http::Pushed {
335− crate::git_http::Pushed { git_ref: git_ref.into(), before: before.map(str::to_owned), after: after.into() }
346+ crate::git_http::Pushed { git_ref: git_ref.into(), before: before.map(str::to_owned), after: after.into(), peeled: None }
336347 }
337348
349+ #[test]
350+ fn an_annotated_tag_not_yet_advertised_is_announced_at_the_commit_its_pack_names() {
351+ // `git push origin v0.0.0-tagtest2`: the store neither logs nor
352+ // advertises the new tag yet; its object in the pack names main.
353+ let git = with_refs(&[("main", "m2")]);
354+ let refs = advertised(&[("refs/heads/main", "m2")]);
355+ let tag = crate::git_http::Pushed { peeled: Some("m2".into()), ..push("refs/tags/v0.0.0-tagtest2", None, "430024c2") };
356+ assert_eq!(run(pushed_to(&git, &tag, Some(&refs))).unwrap().as_deref(), Some("m2"));
357+ assert_eq!(run(pushed_to(&git, &tag, None)).unwrap().as_deref(), Some("m2"));
358+ }
359+
338360 fn with_refs(refs: &[(&str, &str)]) -> Fake {
339361 Fake { refs: refs.iter().map(|&(name, at)| (name.to_owned(), at.to_owned())).collect(), ..Fake::with(history()) }
340362 }
366388 // A lightweight tag has no peeled line: it is its commit.
367389 let refs = advertised(&[("refs/tags/v1", "f2")]);
368390 assert_eq!(run(pushed_to(&git, &push("refs/tags/v1", None, "f2"), Some(&refs))).unwrap().as_deref(), Some("f2"));
369− // Left elsewhere, or not there at all: refused.
391+ // Left elsewhere: refused.
370392 assert_eq!(run(pushed_to(&git, &push("refs/tags/v1", Some("f2"), "m1"), Some(&refs))).unwrap(), None);
371− assert_eq!(run(pushed_to(&git, &push("refs/tags/v2", None, "m1"), Some(&refs))).unwrap(), None);
393+ // Not advertised yet, with nothing peeled: the log decides, as before.
394+ assert_eq!(run(pushed_to(&git, &push("refs/tags/v2", None, "m1"), Some(&refs))).unwrap().as_deref(), Some("m1"));
372395 }
373396
374397 #[test]

Comments

Sign in to comment.