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 new repository's first push closes the issues its commits name: on flagon-io/demo the session pushed the first version with Closes #1, and #1 stayed open, so the session closed it by hand. repos' pushed lists the commits a push brought in only when the branch existed before, since a new branch's commits were pushed elsewhere first; but the push that makes the default branch is the repository's first, and nothing was pushed before it. PushedArgs has first, which work sets for a push to the default branch with no before, and their messages count then. The pull requests guide says so under Closing issues. Checked: cargo test -p g1t-repos pushed (9, one new), cargo test -p g1t-work pushed (6).

G1t-Session:
ses_01m4z09g22e7ysqpg2ha423cws
syntaqxcommitted Parentcbfaa68Browse files
4 files+22−30/4 viewed
+4−1
518518 **closed this in** that commit, its page shows **Closed by commit**, and
519519 the commit's page lists the issues it closed. `issue.closed` carries the
520520 commit as `commit`, and an issue has `resolved_commit` and
521−`resolved_pushed_by`; reopening it clears both. Commits pushed to other
521+`resolved_pushed_by`; reopening it clears both. A push that makes a new
522+branch reads none of its commits, since they were pushed before, except a
523+repository's first push, which makes its default branch: `Closes #1` in
524+the first version of a new repository closes #1. Commits pushed to other
522525 branches close nothing until they reach the default branch, and
523526 `auto_close_issues` turns this off as well.
524527
+4−0
625625 /// Whether to list the commits brought in, with their messages.
626626 #[serde(default)]
627627 pub messages: bool,
628+ /// The push made the default branch: the repository's first, whose
629+ /// commits were pushed nowhere before, so their messages count too.
630+ #[serde(default)]
631+ pub first: bool,
628632 }
629633
630634 /// What `pushed` found.
+12−2
8282 landed.push(head.clone());
8383 }
8484 // A new branch brought nothing to tell anyone about: its commits were
85− // pushed elsewhere first, or are the repository's first.
86− let commits = if a.messages && a.before.is_some() {
85+ // pushed elsewhere first. The default branch's first push is the
86+ // exception: nothing was pushed before it.
87+ let commits = if a.messages && (a.before.is_some() || a.first) {
8788 new.iter()
8889 .take(MAX_PUSHED)
8990 .rev()
183184 after: after.into(),
184185 heads: heads.iter().map(|&h| h.to_owned()).collect(),
185186 messages: true,
187+ first: false,
186188 }
187189 }
188190
253255 }
254256
255257 #[test]
258+ fn the_default_branchs_first_push_lists_its_messages() {
259+ // An empty repository's first push: its `Closes #1` closes #1.
260+ let git = Fake::with(vec![commit("m1", &[]), commit("m2", &["m1"])]);
261+ let pushed = run(brought_in(&git, PushedArgs { first: true, ..args(None, "m2", &[]) })).unwrap();
262+ assert_eq!(hashes(&pushed), vec!["m1", "m2"]);
263+ }
264+
265+ #[test]
256266 fn a_merged_branch_is_read_in_one_go() {
257267 // Twenty commits on a side branch merged in: one read of main and
258268 // one of the side line, not one per commit.
+2−0
113113 after: after.to_owned(),
114114 heads: candidates.iter().map(|row| row.head_commit.clone()).collect(),
115115 messages: closes_issues,
116+ // No `before` on the default branch: the repository's first push.
117+ first: default && event.data["before"].as_str().is_none(),
116118 },
117119 )
118120 .await?;

Comments

Sign in to comment.