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 session's touched branches are branches: on flagon-io/session-lab #2 the session's `git push … | tail` was recorded as touching a branch named "|", since branch_in read every word after git push. It now reads git push's own words only, up to a pipe, a redirect or the next command. Checked: cargo test -p g1t-integrations (76, the pipe, redirect and && cases new).

G1t-Session:
ses_01m4z09g22e7ysqpg2ha423cws
syntaqxcommitted Parent4e63b3fBrowse files
1 file+11−10/1 viewed
+11−1
471471 return next(1).map(str::to_owned);
472472 }
473473 "push" if at > 0 && words[at - 1] == "git" || at > 1 && words[at - 2] == "git" => {
474− let rest: Vec<&str> = words[at + 1..].iter().copied().filter(|w| !w.starts_with('-')).collect();
474+ // Its own words only: a pipe, a redirect or the next command is not a branch.
475+ let rest: Vec<&str> = words[at + 1..]
476+ .iter()
477+ .copied()
478+ .take_while(|w| !w.contains(['|', '>', '<']) && !matches!(*w, "&&" | ";" | "&"))
479+ .filter(|w| !w.starts_with('-'))
480+ .collect();
475481 if let Some(branch) = rest.get(1) {
476482 let branch = branch.trim_matches(|c| c == ';' || c == '&');
477483 let branch = branch.rsplit(':').next().unwrap_or(branch).trim_start_matches("refs/heads/");
17451751 assert_eq!(branch_in("git checkout -b 4-greet"), Some("4-greet".into()));
17461752 assert_eq!(branch_in("cd web && git push origin HEAD:4-greet"), Some("4-greet".into()));
17471753 assert_eq!(branch_in("git status"), None);
1754+ // A pipe or a redirect is not a branch.
1755+ assert_eq!(branch_in("git push -u origin 2-age 2>&1 | tail -3"), Some("2-age".into()));
1756+ assert_eq!(branch_in("git push origin | tail -1"), None);
1757+ assert_eq!(branch_in("git push origin && g1t pr checks"), None);
17481758 assert_eq!(summarize("bash", &json!({ "command": "curl -H x token=abc" })), "bash: curl -H x …");
17491759 }
17501760

Comments

Sign in to comment.