upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-02-16 22:31:29 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-02-16 22:31:29 +0000
commit701668b02d999af42f51d8bd25fffb2a8692c3c8 (patch)
tree7defd0e7e711d743c8464994c2223a7a332ccf2a
parent61ffbf2008c0aaaee3d19ac027d63bca823dc8c9 (diff)
refactor: rename PR to proposal
PR is a problematic term when it ambiguous whether the set of patches are PR-like or email-patch like.
-rw-r--r--src/git.rs24
-rw-r--r--src/main.rs2
-rw-r--r--src/sub_commands/list.rs54
-rw-r--r--src/sub_commands/pull.rs21
-rw-r--r--src/sub_commands/push.rs59
-rw-r--r--src/sub_commands/send.rs4
-rw-r--r--tests/list.rs236
-rw-r--r--tests/pull.rs56
-rw-r--r--tests/push.rs62
-rw-r--r--tests/send.rs95
10 files changed, 315 insertions, 298 deletions
diff --git a/src/git.rs b/src/git.rs
index 13d56f3..faeb9f9 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -372,7 +372,7 @@ impl RepoActions for Repo {
372 if let Ok(last_patch) = patches_to_apply.last().context("no patches") { 372 if let Ok(last_patch) = patches_to_apply.last().context("no patches") {
373 last_patch 373 last_patch
374 } else { 374 } else {
375 self.checkout(branch_name).context("latest commit in pr doesnt connect with an existing commit. Try a git pull on master first.")?; 375 self.checkout(branch_name).context("latest commit in proposal doesnt connect with an existing commit. Try a git pull on master first.")?;
376 return Ok(vec![]); 376 return Ok(vec![]);
377 }, 377 },
378 "parent-commit", 378 "parent-commit",
@@ -387,9 +387,9 @@ impl RepoActions for Repo {
387 if let Ok(current_tip) = self.get_tip_of_local_branch(branch_name) { 387 if let Ok(current_tip) = self.get_tip_of_local_branch(branch_name) {
388 if !current_tip.to_string().eq(&parent_commit_id) { 388 if !current_tip.to_string().eq(&parent_commit_id) {
389 // TODO: either changes have been made on the local branch or 389 // TODO: either changes have been made on the local branch or
390 // the latest commit in the pr has rebased onto a newer commit 390 // the latest commit in the prpoosal has rebased onto a newer
391 // that you havn't pulled yet ask user whether 391 // commit that you havn't pulled yet ask user
392 // they want to proceed 392 // whether they want to proceed
393 } 393 }
394 } 394 }
395 395
@@ -1408,20 +1408,22 @@ mod tests {
1408 use test_utils::TEST_KEY_1_KEYS; 1408 use test_utils::TEST_KEY_1_KEYS;
1409 1409
1410 use super::*; 1410 use super::*;
1411 use crate::{repo_ref::RepoRef, sub_commands::send::generate_pr_and_patch_events}; 1411 use crate::{
1412 repo_ref::RepoRef, sub_commands::send::generate_cover_letter_and_patch_events,
1413 };
1412 1414
1413 static BRANCH_NAME: &str = "add-example-feature"; 1415 static BRANCH_NAME: &str = "add-example-feature";
1414 // returns original_repo, pr_event, patch_events 1416 // returns original_repo, cover_letter_event, patch_events
1415 fn generate_test_repo_and_events() -> Result<(GitTestRepo, nostr::Event, Vec<nostr::Event>)> 1417 fn generate_test_repo_and_events() -> Result<(GitTestRepo, nostr::Event, Vec<nostr::Event>)>
1416 { 1418 {
1417 let original_repo = GitTestRepo::default(); 1419 let original_repo = GitTestRepo::default();
1418 let oid3 = original_repo.populate_with_test_branch()?; 1420 let oid3 = original_repo.populate_with_test_branch()?;
1419 let oid2 = original_repo.git_repo.find_commit(oid3)?.parent_id(0)?; 1421 let oid2 = original_repo.git_repo.find_commit(oid3)?.parent_id(0)?;
1420 let oid1 = original_repo.git_repo.find_commit(oid2)?.parent_id(0)?; 1422 let oid1 = original_repo.git_repo.find_commit(oid2)?.parent_id(0)?;
1421 // TODO: generate pr and patch events 1423 // TODO: generate cover_letter and patch events
1422 let git_repo = Repo::from_path(&original_repo.dir)?; 1424 let git_repo = Repo::from_path(&original_repo.dir)?;
1423 1425
1424 let mut events = generate_pr_and_patch_events( 1426 let mut events = generate_cover_letter_and_patch_events(
1425 Some(("test".to_string(), "test".to_string())), 1427 Some(("test".to_string(), "test".to_string())),
1426 &git_repo, 1428 &git_repo,
1427 &vec![oid_to_sha1(&oid1), oid_to_sha1(&oid2), oid_to_sha1(&oid3)], 1429 &vec![oid_to_sha1(&oid1), oid_to_sha1(&oid2), oid_to_sha1(&oid3)],
@@ -1441,7 +1443,7 @@ mod tests {
1441 use super::*; 1443 use super::*;
1442 1444
1443 #[test] 1445 #[test]
1444 fn branch_gets_created_with_name_specified_in_pr() -> Result<()> { 1446 fn branch_gets_created_with_name_specified_in_proposal() -> Result<()> {
1445 let (_, _, patch_events) = generate_test_repo_and_events()?; 1447 let (_, _, patch_events) = generate_test_repo_and_events()?;
1446 let test_repo = GitTestRepo::default(); 1448 let test_repo = GitTestRepo::default();
1447 test_repo.populate()?; 1449 test_repo.populate()?;
@@ -1530,7 +1532,7 @@ mod tests {
1530 use super::*; 1532 use super::*;
1531 1533
1532 #[test] 1534 #[test]
1533 fn branch_gets_created_with_name_specified_in_pr() -> Result<()> { 1535 fn branch_gets_created_with_name_specified_in_proposal() -> Result<()> {
1534 let (_, _, patch_events) = generate_test_repo_and_events()?; 1536 let (_, _, patch_events) = generate_test_repo_and_events()?;
1535 let test_repo = GitTestRepo::default(); 1537 let test_repo = GitTestRepo::default();
1536 test_repo.populate()?; 1538 test_repo.populate()?;
@@ -1609,7 +1611,7 @@ mod tests {
1609 } 1611 }
1610 } 1612 }
1611 1613
1612 // TODO when_pr_root_is_tip_ahead_of_main_and_doesnt_exist 1614 // TODO when_proposal_root_is_tip_ahead_of_main_and_doesnt_exist
1613 } 1615 }
1614 1616
1615 mod when_branch_and_first_commits_exists { 1617 mod when_branch_and_first_commits_exists {
diff --git a/src/main.rs b/src/main.rs
index 82a87c8..f60edd8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -41,7 +41,7 @@ enum Commands {
41 List(sub_commands::list::SubCommandArgs), 41 List(sub_commands::list::SubCommandArgs),
42 /// send new commits as proposal ammendments 42 /// send new commits as proposal ammendments
43 Push, 43 Push,
44 /// pull latest commits in pr linked to checked out branch 44 /// pull latest commits in proposal linked to checked out branch
45 Pull, 45 Pull,
46 /// run with --nsec flag to change npub 46 /// run with --nsec flag to change npub
47 Login(sub_commands::login::SubCommandArgs), 47 Login(sub_commands::login::SubCommandArgs),
diff --git a/src/sub_commands/list.rs b/src/sub_commands/list.rs
index 4764adc..b8c2919 100644
--- a/src/sub_commands/list.rs
+++ b/src/sub_commands/list.rs
@@ -46,21 +46,21 @@ pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> {
46 ) 46 )
47 .await?; 47 .await?;
48 48
49 println!("finding PRs..."); 49 println!("finding proposals...");
50 50
51 let pr_events: Vec<nostr::Event> = 51 let proposal_events: Vec<nostr::Event> =
52 find_pr_events(&client, &repo_ref, &root_commit.to_string()).await?; 52 find_proposal_events(&client, &repo_ref, &root_commit.to_string()).await?;
53 53
54 if pr_events.is_empty() { 54 if proposal_events.is_empty() {
55 println!("no PRs found... create one? try `ngit send`"); 55 println!("no proposals found... create one? try `ngit send`");
56 return Ok(()); 56 return Ok(());
57 } 57 }
58 58
59 let selected_index = Interactor::default().choice( 59 let selected_index = Interactor::default().choice(
60 PromptChoiceParms::default() 60 PromptChoiceParms::default()
61 .with_prompt("All PRs") 61 .with_prompt("all proposals")
62 .with_choices( 62 .with_choices(
63 pr_events 63 proposal_events
64 .iter() 64 .iter()
65 .map(|e| { 65 .map(|e| {
66 if let Ok(cl) = event_to_cover_letter(e) { 66 if let Ok(cl) = event_to_cover_letter(e) {
@@ -78,26 +78,27 @@ pub async fn launch(_cli_args: &Cli, _args: &SubCommandArgs) -> Result<()> {
78 println!("finding commits..."); 78 println!("finding commits...");
79 79
80 let commits_events: Vec<nostr::Event> = 80 let commits_events: Vec<nostr::Event> =
81 find_commits_for_pr_event(&client, &pr_events[selected_index], &repo_ref).await?; 81 find_commits_for_proposal_root_event(&client, &proposal_events[selected_index], &repo_ref)
82 .await?;
82 83
83 confirm_checkout(&git_repo)?; 84 confirm_checkout(&git_repo)?;
84 85
85 let most_recent_pr_patch_chain = get_most_recent_patch_with_ancestors(commits_events) 86 let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commits_events)
86 .context("cannot get most recent patch for PR")?; 87 .context("cannot get most recent patch for proposal")?;
87 88
88 let branch_name: String = event_to_cover_letter(&pr_events[selected_index]) 89 let branch_name: String = event_to_cover_letter(&proposal_events[selected_index])
89 .context("cannot assign a branch name as event is not a patch set root")? 90 .context("cannot assign a branch name as event is not a patch set root")?
90 .branch_name; 91 .branch_name;
91 92
92 let applied = git_repo 93 let applied = git_repo
93 .apply_patch_chain(&branch_name, most_recent_pr_patch_chain) 94 .apply_patch_chain(&branch_name, most_recent_proposal_patch_chain)
94 .context("cannot apply patch chain")?; 95 .context("cannot apply patch chain")?;
95 96
96 if applied.is_empty() { 97 if applied.is_empty() {
97 println!("checked out PR branch. no new commits to pull"); 98 println!("checked out proposal branch. no new commits to pull");
98 } else { 99 } else {
99 println!( 100 println!(
100 "checked out PR branch. pulled {} new commits", 101 "checked out proposal branch. pulled {} new commits",
101 applied.len(), 102 applied.len(),
102 ); 103 );
103 } 104 }
@@ -115,7 +116,7 @@ fn confirm_checkout(git_repo: &Repo) -> Result<()> {
115 116
116 if git_repo.has_outstanding_changes()? { 117 if git_repo.has_outstanding_changes()? {
117 bail!( 118 bail!(
118 "cannot pull PR branch when repository is not clean. discard or stash (un)staged changes and try again." 119 "cannot pull proposal branch when repository is not clean. discard or stash (un)staged changes and try again."
119 ); 120 );
120 } 121 }
121 Ok(()) 122 Ok(())
@@ -201,7 +202,7 @@ pub fn get_most_recent_patch_with_ancestors(
201 Ok(res) 202 Ok(res)
202} 203}
203 204
204pub async fn find_pr_events( 205pub async fn find_proposal_events(
205 #[cfg(test)] client: &crate::client::MockConnect, 206 #[cfg(test)] client: &crate::client::MockConnect,
206 #[cfg(not(test))] client: &Client, 207 #[cfg(not(test))] client: &Client,
207 repo_ref: &RepoRef, 208 repo_ref: &RepoRef,
@@ -221,7 +222,8 @@ pub async fn find_pr_events(
221 .iter() 222 .iter()
222 .map(|m| format!("{REPO_REF_KIND}:{m}:{}", repo_ref.identifier)), 223 .map(|m| format!("{REPO_REF_KIND}:{m}:{}", repo_ref.identifier)),
223 ), 224 ),
224 // also pick up prs from the same repo but no target at our maintainers repo events 225 // also pick up proposals from the same repo but no target at our maintainers repo
226 // events
225 nostr::Filter::default() 227 nostr::Filter::default()
226 .kind(nostr::Kind::Custom(PATCH_KIND)) 228 .kind(nostr::Kind::Custom(PATCH_KIND))
227 .custom_tag(nostr::Alphabet::T, vec!["root"]) 229 .custom_tag(nostr::Alphabet::T, vec!["root"])
@@ -229,7 +231,7 @@ pub async fn find_pr_events(
229 ], 231 ],
230 ) 232 )
231 .await 233 .await
232 .context("cannot get pr events")? 234 .context("cannot get proposal events")?
233 .iter() 235 .iter()
234 .filter(|e| { 236 .filter(|e| {
235 event_is_patch_set_root(e) 237 event_is_patch_set_root(e)
@@ -250,10 +252,10 @@ pub async fn find_pr_events(
250 .collect::<Vec<nostr::Event>>()) 252 .collect::<Vec<nostr::Event>>())
251} 253}
252 254
253pub async fn find_commits_for_pr_event( 255pub async fn find_commits_for_proposal_root_event(
254 #[cfg(test)] client: &crate::client::MockConnect, 256 #[cfg(test)] client: &crate::client::MockConnect,
255 #[cfg(not(test))] client: &Client, 257 #[cfg(not(test))] client: &Client,
256 pr_event: &nostr::Event, 258 proposal_root_event: &nostr::Event,
257 repo_ref: &RepoRef, 259 repo_ref: &RepoRef,
258) -> Result<Vec<nostr::Event>> { 260) -> Result<Vec<nostr::Event>> {
259 let mut patch_events: Vec<nostr::Event> = client 261 let mut patch_events: Vec<nostr::Event> = client
@@ -265,7 +267,7 @@ pub async fn find_commits_for_pr_event(
265 // this requires every patch to reference the root event 267 // this requires every patch to reference the root event
266 // this will not pick up v2,v3 patch sets 268 // this will not pick up v2,v3 patch sets
267 // TODO: fetch commits for v2.. patch sets 269 // TODO: fetch commits for v2.. patch sets
268 .event(pr_event.id), 270 .event(proposal_root_event.id),
269 ], 271 ],
270 ) 272 )
271 .await 273 .await
@@ -273,15 +275,15 @@ pub async fn find_commits_for_pr_event(
273 .iter() 275 .iter()
274 .filter(|e| { 276 .filter(|e| {
275 e.kind.as_u64() == PATCH_KIND 277 e.kind.as_u64() == PATCH_KIND
276 && e.tags 278 && e.tags.iter().any(|t| {
277 .iter() 279 t.as_vec().len() > 2 && t.as_vec()[1].eq(&proposal_root_event.id.to_string())
278 .any(|t| t.as_vec().len() > 2 && t.as_vec()[1].eq(&pr_event.id.to_string())) 280 })
279 }) 281 })
280 .map(std::borrow::ToOwned::to_owned) 282 .map(std::borrow::ToOwned::to_owned)
281 .collect(); 283 .collect();
282 284
283 if !event_is_cover_letter(pr_event) { 285 if !event_is_cover_letter(proposal_root_event) {
284 patch_events.push(pr_event.clone()); 286 patch_events.push(proposal_root_event.clone());
285 } 287 }
286 Ok(patch_events) 288 Ok(patch_events)
287} 289}
diff --git a/src/sub_commands/pull.rs b/src/sub_commands/pull.rs
index fc6db37..de078e3 100644
--- a/src/sub_commands/pull.rs
+++ b/src/sub_commands/pull.rs
@@ -9,7 +9,8 @@ use crate::{
9 git::{Repo, RepoActions}, 9 git::{Repo, RepoActions},
10 repo_ref, 10 repo_ref,
11 sub_commands::{ 11 sub_commands::{
12 list::get_most_recent_patch_with_ancestors, push::fetch_pr_and_most_recent_patch_chain, 12 list::get_most_recent_patch_with_ancestors,
13 push::fetch_proposal_root_and_most_recent_patch_chain,
13 }, 14 },
14}; 15};
15 16
@@ -29,7 +30,7 @@ pub async fn launch() -> Result<()> {
29 .context("cannot get checked out branch name")?; 30 .context("cannot get checked out branch name")?;
30 31
31 if branch_name == main_or_master_branch_name { 32 if branch_name == main_or_master_branch_name {
32 bail!("checkout a branch associated with a PR first") 33 bail!("checkout a branch associated with a proposal first")
33 } 34 }
34 #[cfg(not(test))] 35 #[cfg(not(test))]
35 let client = Client::default(); 36 let client = Client::default();
@@ -44,19 +45,23 @@ pub async fn launch() -> Result<()> {
44 ) 45 )
45 .await?; 46 .await?;
46 47
47 let (_pr_event, commit_events) = 48 let (_proposal_root_event, commit_events) = fetch_proposal_root_and_most_recent_patch_chain(
48 fetch_pr_and_most_recent_patch_chain(&client, &repo_ref, &root_commit, &branch_name) 49 &client,
49 .await?; 50 &repo_ref,
51 &root_commit,
52 &branch_name,
53 )
54 .await?;
50 55
51 if git_repo.has_outstanding_changes()? { 56 if git_repo.has_outstanding_changes()? {
52 bail!("cannot pull changes when repository is not clean. discard changes and try again."); 57 bail!("cannot pull changes when repository is not clean. discard changes and try again.");
53 } 58 }
54 59
55 let most_recent_pr_patch_chain = get_most_recent_patch_with_ancestors(commit_events) 60 let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events)
56 .context("cannot get most recent patch for PR")?; 61 .context("cannot get most recent patch for proposal")?;
57 62
58 let applied = git_repo 63 let applied = git_repo
59 .apply_patch_chain(&branch_name, most_recent_pr_patch_chain) 64 .apply_patch_chain(&branch_name, most_recent_proposal_patch_chain)
60 .context("cannot apply patch chain")?; 65 .context("cannot apply patch chain")?;
61 66
62 if applied.is_empty() { 67 if applied.is_empty() {
diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs
index 7c6b95b..0fdd56f 100644
--- a/src/sub_commands/push.rs
+++ b/src/sub_commands/push.rs
@@ -12,7 +12,7 @@ use crate::{
12 repo_ref::{self, RepoRef}, 12 repo_ref::{self, RepoRef},
13 sub_commands::{ 13 sub_commands::{
14 list::{ 14 list::{
15 find_commits_for_pr_event, find_pr_events, get_commit_id_from_patch, 15 find_commits_for_proposal_root_event, find_proposal_events, get_commit_id_from_patch,
16 get_most_recent_patch_with_ancestors, tag_value, 16 get_most_recent_patch_with_ancestors, tag_value,
17 }, 17 },
18 send::{event_to_cover_letter, generate_patch_event, send_events}, 18 send::{event_to_cover_letter, generate_patch_event, send_events},
@@ -36,7 +36,7 @@ pub async fn launch(cli_args: &Cli) -> Result<()> {
36 .context("cannot get checked out branch name")?; 36 .context("cannot get checked out branch name")?;
37 37
38 if branch_name == main_or_master_branch_name { 38 if branch_name == main_or_master_branch_name {
39 bail!("checkout a branch associated with a PR first") 39 bail!("checkout a branch associated with a proposal first")
40 } 40 }
41 #[cfg(not(test))] 41 #[cfg(not(test))]
42 let mut client = Client::default(); 42 let mut client = Client::default();
@@ -51,44 +51,48 @@ pub async fn launch(cli_args: &Cli) -> Result<()> {
51 ) 51 )
52 .await?; 52 .await?;
53 53
54 let (pr_event, commit_events) = 54 let (proposal_root_event, commit_events) = fetch_proposal_root_and_most_recent_patch_chain(
55 fetch_pr_and_most_recent_patch_chain(&client, &repo_ref, &root_commit, &branch_name) 55 &client,
56 .await?; 56 &repo_ref,
57 &root_commit,
58 &branch_name,
59 )
60 .await?;
57 61
58 // TODO: fix these scenarios: 62 // TODO: fix these scenarios:
59 // - local PR branch is 2 behind and 1 ahead. intructions: ... 63 // - local proposal branch is 2 behind and 1 ahead. intructions: ...
60 // - PR has been rebased. (against commit in main) instructions: ... 64 // - proposal has been rebased. (against commit in main) instructions: ...
61 // - PR has been rebased. (against commit not in repo) instructions: .. 65 // - proposal has been rebased. (against commit not in repo) instructions: ..
62 66
63 let most_recent_pr_patch_chain = get_most_recent_patch_with_ancestors(commit_events) 67 let most_recent_proposal_patch_chain = get_most_recent_patch_with_ancestors(commit_events)
64 .context("cannot get most recent patch for PR")?; 68 .context("cannot get most recent patch for proposal")?;
65 69
66 let branch_tip = git_repo.get_tip_of_local_branch(&branch_name)?; 70 let branch_tip = git_repo.get_tip_of_local_branch(&branch_name)?;
67 71
68 let most_recent_patch_commit_id = str_to_sha1( 72 let most_recent_patch_commit_id = str_to_sha1(
69 &get_commit_id_from_patch(&most_recent_pr_patch_chain[0]) 73 &get_commit_id_from_patch(&most_recent_proposal_patch_chain[0])
70 .context("latest patch event doesnt have a commit tag")?, 74 .context("latest patch event doesnt have a commit tag")?,
71 ) 75 )
72 .context("latest patch event commit tag isn't a valid SHA1 hash")?; 76 .context("latest patch event commit tag isn't a valid SHA1 hash")?;
73 77
74 if most_recent_patch_commit_id.eq(&branch_tip) { 78 if most_recent_patch_commit_id.eq(&branch_tip) {
75 bail!("nostr pr already up-to-date with local branch"); 79 bail!("nostr proposal already up-to-date with local branch");
76 } 80 }
77 81
78 if most_recent_pr_patch_chain.iter().any(|e| { 82 if most_recent_proposal_patch_chain.iter().any(|e| {
79 let c = tag_value(e, "parent-commit").unwrap_or_default(); 83 let c = tag_value(e, "parent-commit").unwrap_or_default();
80 c.eq(&branch_tip.to_string()) 84 c.eq(&branch_tip.to_string())
81 }) { 85 }) {
82 bail!("nostr pr is ahead of local branch"); 86 bail!("nostr proposal is ahead of local branch");
83 } 87 }
84 88
85 let (ahead, behind) = git_repo 89 let (ahead, behind) = git_repo
86 .get_commits_ahead_behind(&most_recent_patch_commit_id, &branch_tip) 90 .get_commits_ahead_behind(&most_recent_patch_commit_id, &branch_tip)
87 .context("the latest patch in pr doesnt share an ancestor with your branch.")?; 91 .context("the latest patch in proposal doesnt share an ancestor with your branch.")?;
88 92
89 if !behind.is_empty() { 93 if !behind.is_empty() {
90 bail!( 94 bail!(
91 "your local pr branch is {} behind patches on nostr. consider rebasing or force pushing", 95 "your local proposal branch is {} behind patches on nostr. consider rebasing or force pushing",
92 behind.len() 96 behind.len()
93 ) 97 )
94 } 98 }
@@ -109,7 +113,7 @@ pub async fn launch(cli_args: &Cli) -> Result<()> {
109 &git_repo, 113 &git_repo,
110 &root_commit, 114 &root_commit,
111 commit, 115 commit,
112 Some(pr_event.id), 116 Some(proposal_root_event.id),
113 &keys, 117 &keys,
114 &repo_ref, 118 &repo_ref,
115 patch_events.last().map(nostr::Event::id), 119 patch_events.last().map(nostr::Event::id),
@@ -135,33 +139,34 @@ pub async fn launch(cli_args: &Cli) -> Result<()> {
135 Ok(()) 139 Ok(())
136} 140}
137 141
138pub async fn fetch_pr_and_most_recent_patch_chain( 142pub async fn fetch_proposal_root_and_most_recent_patch_chain(
139 #[cfg(test)] client: &crate::client::MockConnect, 143 #[cfg(test)] client: &crate::client::MockConnect,
140 #[cfg(not(test))] client: &Client, 144 #[cfg(not(test))] client: &Client,
141 repo_ref: &RepoRef, 145 repo_ref: &RepoRef,
142 root_commit: &Sha1Hash, 146 root_commit: &Sha1Hash,
143 branch_name: &String, 147 branch_name: &String,
144) -> Result<(nostr::Event, Vec<nostr::Event>)> { 148) -> Result<(nostr::Event, Vec<nostr::Event>)> {
145 println!("finding PR event..."); 149 println!("finding proposal root event...");
146 150
147 let pr_events: Vec<nostr::Event> = find_pr_events(client, repo_ref, &root_commit.to_string()) 151 let proposal_events: Vec<nostr::Event> =
148 .await 152 find_proposal_events(client, repo_ref, &root_commit.to_string())
149 .context("cannot get pr events for repo")?; 153 .await
154 .context("cannot get proposal events for repo")?;
150 155
151 let pr_event: nostr::Event = pr_events 156 let proposal_root_event: nostr::Event = proposal_events
152 .iter() 157 .iter()
153 .find(|e| { 158 .find(|e| {
154 event_to_cover_letter(e).is_ok_and(|cl| cl.branch_name.eq(branch_name)) 159 event_to_cover_letter(e).is_ok_and(|cl| cl.branch_name.eq(branch_name))
155 // TODO remove the dependancy on same branch name and replace with 160 // TODO remove the dependancy on same branch name and replace with
156 // references stored in .git/ngit 161 // references stored in .git/ngit
157 }) 162 })
158 .context("cannot find a PR event associated with the checked out branch name")? 163 .context("cannot find a proposal root event associated with the checked out branch name")?
159 .to_owned(); 164 .to_owned();
160 165
161 println!("found PR event. finding commits..."); 166 println!("found proposal root event. finding commits...");
162 167
163 let commits_events: Vec<nostr::Event> = 168 let commits_events: Vec<nostr::Event> =
164 find_commits_for_pr_event(client, &pr_event, repo_ref).await?; 169 find_commits_for_proposal_root_event(client, &proposal_root_event, repo_ref).await?;
165 170
166 Ok((pr_event, commits_events)) 171 Ok((proposal_root_event, commits_events))
167} 172}
diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs
index b8cb271..3a9da4b 100644
--- a/src/sub_commands/send.rs
+++ b/src/sub_commands/send.rs
@@ -140,7 +140,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
140 // oldest first 140 // oldest first
141 ahead.reverse(); 141 ahead.reverse();
142 142
143 let events = generate_pr_and_patch_events( 143 let events = generate_cover_letter_and_patch_events(
144 cover_letter_title_description.clone(), 144 cover_letter_title_description.clone(),
145 &git_repo, 145 &git_repo,
146 &ahead, 146 &ahead,
@@ -369,7 +369,7 @@ mod tests_unique_and_duplicate {
369 369
370pub static PATCH_KIND: u64 = 1617; 370pub static PATCH_KIND: u64 = 1617;
371 371
372pub fn generate_pr_and_patch_events( 372pub fn generate_cover_letter_and_patch_events(
373 cover_letter_title_description: Option<(String, String)>, 373 cover_letter_title_description: Option<(String, String)>,
374 git_repo: &Repo, 374 git_repo: &Repo,
375 commits: &Vec<Sha1Hash>, 375 commits: &Vec<Sha1Hash>,
diff --git a/tests/list.rs b/tests/list.rs
index 4337d73..e072ff5 100644
--- a/tests/list.rs
+++ b/tests/list.rs
@@ -8,30 +8,30 @@ static FEATURE_BRANCH_NAME_2: &str = "feature-example-f";
8static FEATURE_BRANCH_NAME_3: &str = "feature-example-c"; 8static FEATURE_BRANCH_NAME_3: &str = "feature-example-c";
9static FEATURE_BRANCH_NAME_4: &str = "feature-example-d"; 9static FEATURE_BRANCH_NAME_4: &str = "feature-example-d";
10 10
11static PR_TITLE_1: &str = "pr a"; 11static PROPOSAL_TITLE_1: &str = "proposal a";
12static PR_TITLE_2: &str = "pr b"; 12static PROPOSAL_TITLE_2: &str = "proposal b";
13static PR_TITLE_3: &str = "pr c"; 13static PROPOSAL_TITLE_3: &str = "proposal c";
14 14
15fn cli_tester_create_prs() -> Result<GitTestRepo> { 15fn cli_tester_create_proposals() -> Result<GitTestRepo> {
16 let git_repo = GitTestRepo::default(); 16 let git_repo = GitTestRepo::default();
17 git_repo.populate()?; 17 git_repo.populate()?;
18 cli_tester_create_pr( 18 cli_tester_create_proposal(
19 &git_repo, 19 &git_repo,
20 FEATURE_BRANCH_NAME_1, 20 FEATURE_BRANCH_NAME_1,
21 "a", 21 "a",
22 Some((PR_TITLE_1, "pr a description")), 22 Some((PROPOSAL_TITLE_1, "proposal a description")),
23 )?; 23 )?;
24 cli_tester_create_pr( 24 cli_tester_create_proposal(
25 &git_repo, 25 &git_repo,
26 FEATURE_BRANCH_NAME_2, 26 FEATURE_BRANCH_NAME_2,
27 "b", 27 "b",
28 Some((PR_TITLE_2, "pr b description")), 28 Some((PROPOSAL_TITLE_2, "proposal b description")),
29 )?; 29 )?;
30 cli_tester_create_pr( 30 cli_tester_create_proposal(
31 &git_repo, 31 &git_repo,
32 FEATURE_BRANCH_NAME_3, 32 FEATURE_BRANCH_NAME_3,
33 "c", 33 "c",
34 Some((PR_TITLE_3, "pr c description")), 34 Some((PROPOSAL_TITLE_3, "proposal c description")),
35 )?; 35 )?;
36 Ok(git_repo) 36 Ok(git_repo)
37} 37}
@@ -60,7 +60,7 @@ fn create_and_populate_branch(
60 Ok(()) 60 Ok(())
61} 61}
62 62
63fn cli_tester_create_pr( 63fn cli_tester_create_proposal(
64 test_repo: &GitTestRepo, 64 test_repo: &GitTestRepo,
65 branch_name: &str, 65 branch_name: &str,
66 prefix: &str, 66 prefix: &str,
@@ -158,8 +158,8 @@ mod cannot_find_repo_event {
158 } 158 }
159 .to_bech32()?, 159 .to_bech32()?,
160 )?; 160 )?;
161 p.expect("finding PRs...\r\n")?; 161 p.expect("finding proposals...\r\n")?;
162 p.expect_end_with("no PRs found... create one? try `ngit send`\r\n")?; 162 p.expect_end_with("no proposals found... create one? try `ngit send`\r\n")?;
163 } 163 }
164 if naddr { 164 if naddr {
165 let mut input = p.expect_input("repository naddr or nevent")?; 165 let mut input = p.expect_input("repository naddr or nevent")?;
@@ -172,8 +172,8 @@ mod cannot_find_repo_event {
172 } 172 }
173 .to_bech32()?, 173 .to_bech32()?,
174 )?; 174 )?;
175 p.expect("finding PRs...\r\n")?; 175 p.expect("finding proposals...\r\n")?;
176 p.expect_end_with("no PRs found... create one? try `ngit send`\r\n")?; 176 p.expect_end_with("no proposals found... create one? try `ngit send`\r\n")?;
177 p.expect_end_eventually()?; 177 p.expect_end_eventually()?;
178 } 178 }
179 179
@@ -220,17 +220,17 @@ mod cannot_find_repo_event {
220mod when_main_branch_is_uptodate { 220mod when_main_branch_is_uptodate {
221 use super::*; 221 use super::*;
222 222
223 mod when_pr_branch_doesnt_exist { 223 mod when_proposal_branch_doesnt_exist {
224 use super::*; 224 use super::*;
225 225
226 mod when_main_is_checked_out { 226 mod when_main_is_checked_out {
227 use super::*; 227 use super::*;
228 228
229 mod when_first_pr_selected { 229 mod when_first_proposal_selected {
230 use super::*; 230 use super::*;
231 231
232 // TODO: test when other prs with the same name but from other repositories are 232 // TODO: test when other proposals with the same name but from other
233 // present on relays 233 // repositories are present on relays
234 async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> { 234 async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> {
235 // fallback (51,52) user write (53, 55) repo (55, 56) 235 // fallback (51,52) user write (53, 55) repo (55, 56)
236 let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( 236 let (mut r51, mut r52, mut r53, mut r55, mut r56) = (
@@ -251,19 +251,19 @@ mod when_main_branch_is_uptodate {
251 251
252 let cli_tester_handle = 252 let cli_tester_handle =
253 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { 253 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> {
254 let originating_repo = cli_tester_create_prs()?; 254 let originating_repo = cli_tester_create_proposals()?;
255 255
256 let test_repo = GitTestRepo::default(); 256 let test_repo = GitTestRepo::default();
257 test_repo.populate()?; 257 test_repo.populate()?;
258 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); 258 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]);
259 259
260 p.expect("finding PRs...\r\n")?; 260 p.expect("finding proposals...\r\n")?;
261 let mut c = p.expect_choice( 261 let mut c = p.expect_choice(
262 "All PRs", 262 "all proposals",
263 vec![ 263 vec![
264 format!("\"{PR_TITLE_1}\""), 264 format!("\"{PROPOSAL_TITLE_1}\""),
265 format!("\"{PR_TITLE_2}\""), 265 format!("\"{PROPOSAL_TITLE_2}\""),
266 format!("\"{PR_TITLE_3}\""), 266 format!("\"{PROPOSAL_TITLE_3}\""),
267 ], 267 ],
268 )?; 268 )?;
269 c.succeeds_with(0, true)?; 269 c.succeeds_with(0, true)?;
@@ -293,7 +293,7 @@ mod when_main_branch_is_uptodate {
293 293
294 mod cli_prompts { 294 mod cli_prompts {
295 use super::*; 295 use super::*;
296 async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { 296 async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> {
297 let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( 297 let (mut r51, mut r52, mut r53, mut r55, mut r56) = (
298 Relay::new(8051, None, None), 298 Relay::new(8051, None, None),
299 Relay::new(8052, None, None), 299 Relay::new(8052, None, None),
@@ -311,26 +311,26 @@ mod when_main_branch_is_uptodate {
311 r55.events.push(generate_test_key_1_relay_list_event()); 311 r55.events.push(generate_test_key_1_relay_list_event());
312 312
313 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 313 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
314 cli_tester_create_prs()?; 314 cli_tester_create_proposals()?;
315 315
316 let test_repo = GitTestRepo::default(); 316 let test_repo = GitTestRepo::default();
317 test_repo.populate()?; 317 test_repo.populate()?;
318 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); 318 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]);
319 319
320 p.expect("finding PRs...\r\n")?; 320 p.expect("finding proposals...\r\n")?;
321 let mut c = p.expect_choice( 321 let mut c = p.expect_choice(
322 "All PRs", 322 "all proposals",
323 vec![ 323 vec![
324 format!("\"{PR_TITLE_1}\""), 324 format!("\"{PROPOSAL_TITLE_1}\""),
325 format!("\"{PR_TITLE_2}\""), 325 format!("\"{PROPOSAL_TITLE_2}\""),
326 format!("\"{PR_TITLE_3}\""), 326 format!("\"{PROPOSAL_TITLE_3}\""),
327 ], 327 ],
328 )?; 328 )?;
329 c.succeeds_with(0, true)?; 329 c.succeeds_with(0, true)?;
330 p.expect("finding commits...\r\n")?; 330 p.expect("finding commits...\r\n")?;
331 let mut confirm = p.expect_confirm("check out branch?", Some(true))?; 331 let mut confirm = p.expect_confirm("check out branch?", Some(true))?;
332 confirm.succeeds_with(None)?; 332 confirm.succeeds_with(None)?;
333 p.expect("checked out PR branch. pulled 2 new commits\r\n")?; 333 p.expect("checked out proposal branch. pulled 2 new commits\r\n")?;
334 p.expect_end()?; 334 p.expect_end()?;
335 335
336 for p in [51, 52, 53, 55, 56] { 336 for p in [51, 52, 53, 55, 56] {
@@ -354,15 +354,15 @@ mod when_main_branch_is_uptodate {
354 354
355 #[tokio::test] 355 #[tokio::test]
356 #[serial] 356 #[serial]
357 async fn prompts_to_choose_from_pr_titles() -> Result<()> { 357 async fn prompts_to_choose_from_proposal_titles() -> Result<()> {
358 let _ = run_async_prompts_to_choose_from_pr_titles().await; 358 let _ = run_async_prompts_to_choose_from_proposal_titles().await;
359 Ok(()) 359 Ok(())
360 } 360 }
361 } 361 }
362 362
363 #[tokio::test] 363 #[tokio::test]
364 #[serial] 364 #[serial]
365 async fn pr_branch_created_with_correct_name() -> Result<()> { 365 async fn proposal_branch_created_with_correct_name() -> Result<()> {
366 let (_, test_repo) = prep_and_run().await?; 366 let (_, test_repo) = prep_and_run().await?;
367 assert_eq!( 367 assert_eq!(
368 vec![FEATURE_BRANCH_NAME_1, "main"], 368 vec![FEATURE_BRANCH_NAME_1, "main"],
@@ -373,7 +373,7 @@ mod when_main_branch_is_uptodate {
373 373
374 #[tokio::test] 374 #[tokio::test]
375 #[serial] 375 #[serial]
376 async fn pr_branch_checked_out() -> Result<()> { 376 async fn proposal_branch_checked_out() -> Result<()> {
377 let (_, test_repo) = prep_and_run().await?; 377 let (_, test_repo) = prep_and_run().await?;
378 assert_eq!( 378 assert_eq!(
379 FEATURE_BRANCH_NAME_1, 379 FEATURE_BRANCH_NAME_1,
@@ -384,7 +384,7 @@ mod when_main_branch_is_uptodate {
384 384
385 #[tokio::test] 385 #[tokio::test]
386 #[serial] 386 #[serial]
387 async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { 387 async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> {
388 let (originating_repo, test_repo) = prep_and_run().await?; 388 let (originating_repo, test_repo) = prep_and_run().await?;
389 assert_eq!( 389 assert_eq!(
390 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, 390 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?,
@@ -393,7 +393,7 @@ mod when_main_branch_is_uptodate {
393 Ok(()) 393 Ok(())
394 } 394 }
395 } 395 }
396 mod when_third_pr_selected { 396 mod when_third_proposal_selected {
397 use super::*; 397 use super::*;
398 398
399 async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> { 399 async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> {
@@ -416,19 +416,19 @@ mod when_main_branch_is_uptodate {
416 416
417 let cli_tester_handle = 417 let cli_tester_handle =
418 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { 418 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> {
419 let originating_repo = cli_tester_create_prs()?; 419 let originating_repo = cli_tester_create_proposals()?;
420 420
421 let test_repo = GitTestRepo::default(); 421 let test_repo = GitTestRepo::default();
422 test_repo.populate()?; 422 test_repo.populate()?;
423 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); 423 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]);
424 424
425 p.expect("finding PRs...\r\n")?; 425 p.expect("finding proposals...\r\n")?;
426 let mut c = p.expect_choice( 426 let mut c = p.expect_choice(
427 "All PRs", 427 "all proposals",
428 vec![ 428 vec![
429 format!("\"{PR_TITLE_1}\""), 429 format!("\"{PROPOSAL_TITLE_1}\""),
430 format!("\"{PR_TITLE_2}\""), 430 format!("\"{PROPOSAL_TITLE_2}\""),
431 format!("\"{PR_TITLE_3}\""), 431 format!("\"{PROPOSAL_TITLE_3}\""),
432 ], 432 ],
433 )?; 433 )?;
434 c.succeeds_with(2, true)?; 434 c.succeeds_with(2, true)?;
@@ -458,7 +458,7 @@ mod when_main_branch_is_uptodate {
458 458
459 mod cli_prompts { 459 mod cli_prompts {
460 use super::*; 460 use super::*;
461 async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { 461 async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> {
462 let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( 462 let (mut r51, mut r52, mut r53, mut r55, mut r56) = (
463 Relay::new(8051, None, None), 463 Relay::new(8051, None, None),
464 Relay::new(8052, None, None), 464 Relay::new(8052, None, None),
@@ -476,26 +476,26 @@ mod when_main_branch_is_uptodate {
476 r55.events.push(generate_test_key_1_relay_list_event()); 476 r55.events.push(generate_test_key_1_relay_list_event());
477 477
478 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 478 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
479 cli_tester_create_prs()?; 479 cli_tester_create_proposals()?;
480 480
481 let test_repo = GitTestRepo::default(); 481 let test_repo = GitTestRepo::default();
482 test_repo.populate()?; 482 test_repo.populate()?;
483 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); 483 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]);
484 484
485 p.expect("finding PRs...\r\n")?; 485 p.expect("finding proposals...\r\n")?;
486 let mut c = p.expect_choice( 486 let mut c = p.expect_choice(
487 "All PRs", 487 "all proposals",
488 vec![ 488 vec![
489 format!("\"{PR_TITLE_1}\""), 489 format!("\"{PROPOSAL_TITLE_1}\""),
490 format!("\"{PR_TITLE_2}\""), 490 format!("\"{PROPOSAL_TITLE_2}\""),
491 format!("\"{PR_TITLE_3}\""), 491 format!("\"{PROPOSAL_TITLE_3}\""),
492 ], 492 ],
493 )?; 493 )?;
494 c.succeeds_with(2, true)?; 494 c.succeeds_with(2, true)?;
495 p.expect("finding commits...\r\n")?; 495 p.expect("finding commits...\r\n")?;
496 let mut confirm = p.expect_confirm("check out branch?", Some(true))?; 496 let mut confirm = p.expect_confirm("check out branch?", Some(true))?;
497 confirm.succeeds_with(None)?; 497 confirm.succeeds_with(None)?;
498 p.expect("checked out PR branch. pulled 2 new commits\r\n")?; 498 p.expect("checked out proposal branch. pulled 2 new commits\r\n")?;
499 p.expect_end()?; 499 p.expect_end()?;
500 500
501 for p in [51, 52, 53, 55, 56] { 501 for p in [51, 52, 53, 55, 56] {
@@ -519,15 +519,15 @@ mod when_main_branch_is_uptodate {
519 519
520 #[tokio::test] 520 #[tokio::test]
521 #[serial] 521 #[serial]
522 async fn prompts_to_choose_from_pr_titles() -> Result<()> { 522 async fn prompts_to_choose_from_proposal_titles() -> Result<()> {
523 let _ = run_async_prompts_to_choose_from_pr_titles().await; 523 let _ = run_async_prompts_to_choose_from_proposal_titles().await;
524 Ok(()) 524 Ok(())
525 } 525 }
526 } 526 }
527 527
528 #[tokio::test] 528 #[tokio::test]
529 #[serial] 529 #[serial]
530 async fn pr_branch_created_with_correct_name() -> Result<()> { 530 async fn proposal_branch_created_with_correct_name() -> Result<()> {
531 let (_, test_repo) = prep_and_run().await?; 531 let (_, test_repo) = prep_and_run().await?;
532 assert_eq!( 532 assert_eq!(
533 vec![FEATURE_BRANCH_NAME_3, "main"], 533 vec![FEATURE_BRANCH_NAME_3, "main"],
@@ -538,7 +538,7 @@ mod when_main_branch_is_uptodate {
538 538
539 #[tokio::test] 539 #[tokio::test]
540 #[serial] 540 #[serial]
541 async fn pr_branch_checked_out() -> Result<()> { 541 async fn proposal_branch_checked_out() -> Result<()> {
542 let (_, test_repo) = prep_and_run().await?; 542 let (_, test_repo) = prep_and_run().await?;
543 assert_eq!( 543 assert_eq!(
544 FEATURE_BRANCH_NAME_3, 544 FEATURE_BRANCH_NAME_3,
@@ -549,7 +549,7 @@ mod when_main_branch_is_uptodate {
549 549
550 #[tokio::test] 550 #[tokio::test]
551 #[serial] 551 #[serial]
552 async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { 552 async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> {
553 let (originating_repo, test_repo) = prep_and_run().await?; 553 let (originating_repo, test_repo) = prep_and_run().await?;
554 assert_eq!( 554 assert_eq!(
555 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_3)?, 555 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_3)?,
@@ -558,7 +558,7 @@ mod when_main_branch_is_uptodate {
558 Ok(()) 558 Ok(())
559 } 559 }
560 } 560 }
561 mod when_forth_pr_has_no_cover_letter { 561 mod when_forth_proposal_has_no_cover_letter {
562 use super::*; 562 use super::*;
563 563
564 async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> { 564 async fn prep_and_run() -> Result<(GitTestRepo, GitTestRepo)> {
@@ -581,8 +581,8 @@ mod when_main_branch_is_uptodate {
581 581
582 let cli_tester_handle = 582 let cli_tester_handle =
583 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { 583 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> {
584 let originating_repo = cli_tester_create_prs()?; 584 let originating_repo = cli_tester_create_proposals()?;
585 cli_tester_create_pr( 585 cli_tester_create_proposal(
586 &originating_repo, 586 &originating_repo,
587 FEATURE_BRANCH_NAME_4, 587 FEATURE_BRANCH_NAME_4,
588 "d", 588 "d",
@@ -592,13 +592,13 @@ mod when_main_branch_is_uptodate {
592 test_repo.populate()?; 592 test_repo.populate()?;
593 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); 593 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]);
594 594
595 p.expect("finding PRs...\r\n")?; 595 p.expect("finding proposals...\r\n")?;
596 let mut c = p.expect_choice( 596 let mut c = p.expect_choice(
597 "All PRs", 597 "all proposals",
598 vec![ 598 vec![
599 format!("\"{PR_TITLE_1}\""), 599 format!("\"{PROPOSAL_TITLE_1}\""),
600 format!("\"{PR_TITLE_2}\""), 600 format!("\"{PROPOSAL_TITLE_2}\""),
601 format!("\"{PR_TITLE_3}\""), 601 format!("\"{PROPOSAL_TITLE_3}\""),
602 format!("add d3.md"), // commit msg title 602 format!("add d3.md"), // commit msg title
603 ], 603 ],
604 )?; 604 )?;
@@ -629,7 +629,7 @@ mod when_main_branch_is_uptodate {
629 629
630 mod cli_prompts { 630 mod cli_prompts {
631 use super::*; 631 use super::*;
632 async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { 632 async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> {
633 let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( 633 let (mut r51, mut r52, mut r53, mut r55, mut r56) = (
634 Relay::new(8051, None, None), 634 Relay::new(8051, None, None),
635 Relay::new(8052, None, None), 635 Relay::new(8052, None, None),
@@ -647,8 +647,8 @@ mod when_main_branch_is_uptodate {
647 r55.events.push(generate_test_key_1_relay_list_event()); 647 r55.events.push(generate_test_key_1_relay_list_event());
648 648
649 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 649 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
650 let originating_repo = cli_tester_create_prs()?; 650 let originating_repo = cli_tester_create_proposals()?;
651 cli_tester_create_pr( 651 cli_tester_create_proposal(
652 &originating_repo, 652 &originating_repo,
653 FEATURE_BRANCH_NAME_4, 653 FEATURE_BRANCH_NAME_4,
654 "d", 654 "d",
@@ -658,13 +658,13 @@ mod when_main_branch_is_uptodate {
658 test_repo.populate()?; 658 test_repo.populate()?;
659 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]); 659 let mut p = CliTester::new_from_dir(&test_repo.dir, ["list"]);
660 660
661 p.expect("finding PRs...\r\n")?; 661 p.expect("finding proposals...\r\n")?;
662 let mut c = p.expect_choice( 662 let mut c = p.expect_choice(
663 "All PRs", 663 "all proposals",
664 vec![ 664 vec![
665 format!("\"{PR_TITLE_1}\""), 665 format!("\"{PROPOSAL_TITLE_1}\""),
666 format!("\"{PR_TITLE_2}\""), 666 format!("\"{PROPOSAL_TITLE_2}\""),
667 format!("\"{PR_TITLE_3}\""), 667 format!("\"{PROPOSAL_TITLE_3}\""),
668 format!("add d3.md"), // commit msg title 668 format!("add d3.md"), // commit msg title
669 ], 669 ],
670 )?; 670 )?;
@@ -672,7 +672,7 @@ mod when_main_branch_is_uptodate {
672 p.expect("finding commits...\r\n")?; 672 p.expect("finding commits...\r\n")?;
673 let mut confirm = p.expect_confirm("check out branch?", Some(true))?; 673 let mut confirm = p.expect_confirm("check out branch?", Some(true))?;
674 confirm.succeeds_with(None)?; 674 confirm.succeeds_with(None)?;
675 p.expect("checked out PR branch. pulled 2 new commits\r\n")?; 675 p.expect("checked out proposal branch. pulled 2 new commits\r\n")?;
676 p.expect_end()?; 676 p.expect_end()?;
677 677
678 for p in [51, 52, 53, 55, 56] { 678 for p in [51, 52, 53, 55, 56] {
@@ -696,15 +696,15 @@ mod when_main_branch_is_uptodate {
696 696
697 #[tokio::test] 697 #[tokio::test]
698 #[serial] 698 #[serial]
699 async fn prompts_to_choose_from_pr_titles() -> Result<()> { 699 async fn prompts_to_choose_from_proposal_titles() -> Result<()> {
700 let _ = run_async_prompts_to_choose_from_pr_titles().await; 700 let _ = run_async_prompts_to_choose_from_proposal_titles().await;
701 Ok(()) 701 Ok(())
702 } 702 }
703 } 703 }
704 704
705 #[tokio::test] 705 #[tokio::test]
706 #[serial] 706 #[serial]
707 async fn pr_branch_created_with_correct_name() -> Result<()> { 707 async fn proposal_branch_created_with_correct_name() -> Result<()> {
708 let (_, test_repo) = prep_and_run().await?; 708 let (_, test_repo) = prep_and_run().await?;
709 assert_eq!( 709 assert_eq!(
710 vec![FEATURE_BRANCH_NAME_4, "main"], 710 vec![FEATURE_BRANCH_NAME_4, "main"],
@@ -715,7 +715,7 @@ mod when_main_branch_is_uptodate {
715 715
716 #[tokio::test] 716 #[tokio::test]
717 #[serial] 717 #[serial]
718 async fn pr_branch_checked_out() -> Result<()> { 718 async fn proposal_branch_checked_out() -> Result<()> {
719 let (_, test_repo) = prep_and_run().await?; 719 let (_, test_repo) = prep_and_run().await?;
720 assert_eq!( 720 assert_eq!(
721 FEATURE_BRANCH_NAME_4, 721 FEATURE_BRANCH_NAME_4,
@@ -726,7 +726,7 @@ mod when_main_branch_is_uptodate {
726 726
727 #[tokio::test] 727 #[tokio::test]
728 #[serial] 728 #[serial]
729 async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { 729 async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> {
730 let (originating_repo, test_repo) = prep_and_run().await?; 730 let (originating_repo, test_repo) = prep_and_run().await?;
731 assert_eq!( 731 assert_eq!(
732 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_4)?, 732 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_4)?,
@@ -738,7 +738,7 @@ mod when_main_branch_is_uptodate {
738 } 738 }
739 } 739 }
740 740
741 mod when_pr_branch_exists { 741 mod when_proposal_branch_exists {
742 use super::*; 742 use super::*;
743 743
744 mod when_main_is_checked_out { 744 mod when_main_is_checked_out {
@@ -766,7 +766,7 @@ mod when_main_branch_is_uptodate {
766 766
767 let cli_tester_handle = 767 let cli_tester_handle =
768 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { 768 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> {
769 let originating_repo = cli_tester_create_prs()?; 769 let originating_repo = cli_tester_create_proposals()?;
770 770
771 let test_repo = GitTestRepo::default(); 771 let test_repo = GitTestRepo::default();
772 test_repo.populate()?; 772 test_repo.populate()?;
@@ -779,13 +779,13 @@ mod when_main_branch_is_uptodate {
779 false, 779 false,
780 )?; 780 )?;
781 test_repo.checkout("main")?; 781 test_repo.checkout("main")?;
782 p.expect("finding PRs...\r\n")?; 782 p.expect("finding proposals...\r\n")?;
783 let mut c = p.expect_choice( 783 let mut c = p.expect_choice(
784 "All PRs", 784 "all proposals",
785 vec![ 785 vec![
786 format!("\"{PR_TITLE_1}\""), 786 format!("\"{PROPOSAL_TITLE_1}\""),
787 format!("\"{PR_TITLE_2}\""), 787 format!("\"{PROPOSAL_TITLE_2}\""),
788 format!("\"{PR_TITLE_3}\""), 788 format!("\"{PROPOSAL_TITLE_3}\""),
789 ], 789 ],
790 )?; 790 )?;
791 c.succeeds_with(0, true)?; 791 c.succeeds_with(0, true)?;
@@ -815,7 +815,7 @@ mod when_main_branch_is_uptodate {
815 815
816 mod cli_prompts { 816 mod cli_prompts {
817 use super::*; 817 use super::*;
818 async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { 818 async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> {
819 let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( 819 let (mut r51, mut r52, mut r53, mut r55, mut r56) = (
820 Relay::new(8051, None, None), 820 Relay::new(8051, None, None),
821 Relay::new(8052, None, None), 821 Relay::new(8052, None, None),
@@ -833,7 +833,7 @@ mod when_main_branch_is_uptodate {
833 r55.events.push(generate_test_key_1_relay_list_event()); 833 r55.events.push(generate_test_key_1_relay_list_event());
834 834
835 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 835 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
836 cli_tester_create_prs()?; 836 cli_tester_create_proposals()?;
837 837
838 let test_repo = GitTestRepo::default(); 838 let test_repo = GitTestRepo::default();
839 test_repo.populate()?; 839 test_repo.populate()?;
@@ -847,20 +847,20 @@ mod when_main_branch_is_uptodate {
847 )?; 847 )?;
848 test_repo.checkout("main")?; 848 test_repo.checkout("main")?;
849 849
850 p.expect("finding PRs...\r\n")?; 850 p.expect("finding proposals...\r\n")?;
851 let mut c = p.expect_choice( 851 let mut c = p.expect_choice(
852 "All PRs", 852 "all proposals",
853 vec![ 853 vec![
854 format!("\"{PR_TITLE_1}\""), 854 format!("\"{PROPOSAL_TITLE_1}\""),
855 format!("\"{PR_TITLE_2}\""), 855 format!("\"{PROPOSAL_TITLE_2}\""),
856 format!("\"{PR_TITLE_3}\""), 856 format!("\"{PROPOSAL_TITLE_3}\""),
857 ], 857 ],
858 )?; 858 )?;
859 c.succeeds_with(0, true)?; 859 c.succeeds_with(0, true)?;
860 p.expect("finding commits...\r\n")?; 860 p.expect("finding commits...\r\n")?;
861 let mut confirm = p.expect_confirm("check out branch?", Some(true))?; 861 let mut confirm = p.expect_confirm("check out branch?", Some(true))?;
862 confirm.succeeds_with(None)?; 862 confirm.succeeds_with(None)?;
863 p.expect("checked out PR branch. no new commits to pull\r\n")?; 863 p.expect("checked out proposal branch. no new commits to pull\r\n")?;
864 p.expect_end()?; 864 p.expect_end()?;
865 865
866 for p in [51, 52, 53, 55, 56] { 866 for p in [51, 52, 53, 55, 56] {
@@ -884,15 +884,15 @@ mod when_main_branch_is_uptodate {
884 884
885 #[tokio::test] 885 #[tokio::test]
886 #[serial] 886 #[serial]
887 async fn prompts_to_choose_from_pr_titles() -> Result<()> { 887 async fn prompts_to_choose_from_proposal_titles() -> Result<()> {
888 let _ = run_async_prompts_to_choose_from_pr_titles().await; 888 let _ = run_async_prompts_to_choose_from_proposal_titles().await;
889 Ok(()) 889 Ok(())
890 } 890 }
891 } 891 }
892 892
893 #[tokio::test] 893 #[tokio::test]
894 #[serial] 894 #[serial]
895 async fn pr_branch_checked_out() -> Result<()> { 895 async fn proposal_branch_checked_out() -> Result<()> {
896 let (_, test_repo) = prep_and_run().await?; 896 let (_, test_repo) = prep_and_run().await?;
897 assert_eq!( 897 assert_eq!(
898 FEATURE_BRANCH_NAME_1, 898 FEATURE_BRANCH_NAME_1,
@@ -925,7 +925,7 @@ mod when_main_branch_is_uptodate {
925 925
926 let cli_tester_handle = 926 let cli_tester_handle =
927 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { 927 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> {
928 let originating_repo = cli_tester_create_prs()?; 928 let originating_repo = cli_tester_create_proposals()?;
929 929
930 let test_repo = GitTestRepo::default(); 930 let test_repo = GitTestRepo::default();
931 test_repo.populate()?; 931 test_repo.populate()?;
@@ -939,13 +939,13 @@ mod when_main_branch_is_uptodate {
939 )?; 939 )?;
940 test_repo.checkout("main")?; 940 test_repo.checkout("main")?;
941 941
942 p.expect("finding PRs...\r\n")?; 942 p.expect("finding proposals...\r\n")?;
943 let mut c = p.expect_choice( 943 let mut c = p.expect_choice(
944 "All PRs", 944 "all proposals",
945 vec![ 945 vec![
946 format!("\"{PR_TITLE_1}\""), 946 format!("\"{PROPOSAL_TITLE_1}\""),
947 format!("\"{PR_TITLE_2}\""), 947 format!("\"{PROPOSAL_TITLE_2}\""),
948 format!("\"{PR_TITLE_3}\""), 948 format!("\"{PROPOSAL_TITLE_3}\""),
949 ], 949 ],
950 )?; 950 )?;
951 c.succeeds_with(0, true)?; 951 c.succeeds_with(0, true)?;
@@ -975,7 +975,7 @@ mod when_main_branch_is_uptodate {
975 975
976 mod cli_prompts { 976 mod cli_prompts {
977 use super::*; 977 use super::*;
978 async fn run_async_prompts_to_choose_from_pr_titles() -> Result<()> { 978 async fn run_async_prompts_to_choose_from_proposal_titles() -> Result<()> {
979 let (mut r51, mut r52, mut r53, mut r55, mut r56) = ( 979 let (mut r51, mut r52, mut r53, mut r55, mut r56) = (
980 Relay::new(8051, None, None), 980 Relay::new(8051, None, None),
981 Relay::new(8052, None, None), 981 Relay::new(8052, None, None),
@@ -993,7 +993,7 @@ mod when_main_branch_is_uptodate {
993 r55.events.push(generate_test_key_1_relay_list_event()); 993 r55.events.push(generate_test_key_1_relay_list_event());
994 994
995 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 995 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
996 cli_tester_create_prs()?; 996 cli_tester_create_proposals()?;
997 997
998 let test_repo = GitTestRepo::default(); 998 let test_repo = GitTestRepo::default();
999 test_repo.populate()?; 999 test_repo.populate()?;
@@ -1007,20 +1007,20 @@ mod when_main_branch_is_uptodate {
1007 )?; 1007 )?;
1008 test_repo.checkout("main")?; 1008 test_repo.checkout("main")?;
1009 1009
1010 p.expect("finding PRs...\r\n")?; 1010 p.expect("finding proposals...\r\n")?;
1011 let mut c = p.expect_choice( 1011 let mut c = p.expect_choice(
1012 "All PRs", 1012 "all proposals",
1013 vec![ 1013 vec![
1014 format!("\"{PR_TITLE_1}\""), 1014 format!("\"{PROPOSAL_TITLE_1}\""),
1015 format!("\"{PR_TITLE_2}\""), 1015 format!("\"{PROPOSAL_TITLE_2}\""),
1016 format!("\"{PR_TITLE_3}\""), 1016 format!("\"{PROPOSAL_TITLE_3}\""),
1017 ], 1017 ],
1018 )?; 1018 )?;
1019 c.succeeds_with(0, true)?; 1019 c.succeeds_with(0, true)?;
1020 p.expect("finding commits...\r\n")?; 1020 p.expect("finding commits...\r\n")?;
1021 let mut confirm = p.expect_confirm("check out branch?", Some(true))?; 1021 let mut confirm = p.expect_confirm("check out branch?", Some(true))?;
1022 confirm.succeeds_with(None)?; 1022 confirm.succeeds_with(None)?;
1023 p.expect("checked out PR branch. pulled 1 new commits\r\n")?; 1023 p.expect("checked out proposal branch. pulled 1 new commits\r\n")?;
1024 p.expect_end()?; 1024 p.expect_end()?;
1025 1025
1026 for p in [51, 52, 53, 55, 56] { 1026 for p in [51, 52, 53, 55, 56] {
@@ -1044,15 +1044,15 @@ mod when_main_branch_is_uptodate {
1044 1044
1045 #[tokio::test] 1045 #[tokio::test]
1046 #[serial] 1046 #[serial]
1047 async fn prompts_to_choose_from_pr_titles() -> Result<()> { 1047 async fn prompts_to_choose_from_proposal_titles() -> Result<()> {
1048 let _ = run_async_prompts_to_choose_from_pr_titles().await; 1048 let _ = run_async_prompts_to_choose_from_proposal_titles().await;
1049 Ok(()) 1049 Ok(())
1050 } 1050 }
1051 } 1051 }
1052 1052
1053 #[tokio::test] 1053 #[tokio::test]
1054 #[serial] 1054 #[serial]
1055 async fn pr_branch_checked_out() -> Result<()> { 1055 async fn proposal_branch_checked_out() -> Result<()> {
1056 let (_, test_repo) = prep_and_run().await?; 1056 let (_, test_repo) = prep_and_run().await?;
1057 assert_eq!( 1057 assert_eq!(
1058 FEATURE_BRANCH_NAME_1, 1058 FEATURE_BRANCH_NAME_1,
@@ -1063,7 +1063,7 @@ mod when_main_branch_is_uptodate {
1063 1063
1064 #[tokio::test] 1064 #[tokio::test]
1065 #[serial] 1065 #[serial]
1066 async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { 1066 async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> {
1067 let (originating_repo, test_repo) = prep_and_run().await?; 1067 let (originating_repo, test_repo) = prep_and_run().await?;
1068 assert_eq!( 1068 assert_eq!(
1069 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, 1069 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?,
@@ -1075,8 +1075,8 @@ mod when_main_branch_is_uptodate {
1075 1075
1076 mod when_branch_is_ahead { 1076 mod when_branch_is_ahead {
1077 // use super::*; 1077 // use super::*;
1078 // TODO latest commit in pr builds off an older commit in pr 1078 // TODO latest commit in proposal builds off an older commit in
1079 // instead of previous. 1079 // proposal instead of previous.
1080 // TODO current git user created commit on branch 1080 // TODO current git user created commit on branch
1081 } 1081 }
1082 1082
diff --git a/tests/pull.rs b/tests/pull.rs
index d3064a3..7270908 100644
--- a/tests/pull.rs
+++ b/tests/pull.rs
@@ -7,33 +7,33 @@ static FEATURE_BRANCH_NAME_1: &str = "feature-example-t";
7static FEATURE_BRANCH_NAME_2: &str = "feature-example-f"; 7static FEATURE_BRANCH_NAME_2: &str = "feature-example-f";
8static FEATURE_BRANCH_NAME_3: &str = "feature-example-c"; 8static FEATURE_BRANCH_NAME_3: &str = "feature-example-c";
9 9
10static PR_TITLE_1: &str = "pr a"; 10static PROPOSAL_TITLE_1: &str = "proposal a";
11static PR_TITLE_2: &str = "pr b"; 11static PROPOSAL_TITLE_2: &str = "proposal b";
12static PR_TITLE_3: &str = "pr c"; 12static PROPOSAL_TITLE_3: &str = "proposal c";
13 13
14fn cli_tester_create_prs() -> Result<GitTestRepo> { 14fn cli_tester_create_proposals() -> Result<GitTestRepo> {
15 let git_repo = GitTestRepo::default(); 15 let git_repo = GitTestRepo::default();
16 git_repo.populate()?; 16 git_repo.populate()?;
17 cli_tester_create_pr( 17 cli_tester_create_proposal(
18 &git_repo, 18 &git_repo,
19 FEATURE_BRANCH_NAME_1, 19 FEATURE_BRANCH_NAME_1,
20 "a", 20 "a",
21 PR_TITLE_1, 21 PROPOSAL_TITLE_1,
22 "pr a description", 22 "proposal a description",
23 )?; 23 )?;
24 cli_tester_create_pr( 24 cli_tester_create_proposal(
25 &git_repo, 25 &git_repo,
26 FEATURE_BRANCH_NAME_2, 26 FEATURE_BRANCH_NAME_2,
27 "b", 27 "b",
28 PR_TITLE_2, 28 PROPOSAL_TITLE_2,
29 "pr b description", 29 "proposal b description",
30 )?; 30 )?;
31 cli_tester_create_pr( 31 cli_tester_create_proposal(
32 &git_repo, 32 &git_repo,
33 FEATURE_BRANCH_NAME_3, 33 FEATURE_BRANCH_NAME_3,
34 "c", 34 "c",
35 PR_TITLE_3, 35 PROPOSAL_TITLE_3,
36 "pr c description", 36 "proposal c description",
37 )?; 37 )?;
38 Ok(git_repo) 38 Ok(git_repo)
39} 39}
@@ -62,7 +62,7 @@ fn create_and_populate_branch(
62 Ok(()) 62 Ok(())
63} 63}
64 64
65fn cli_tester_create_pr( 65fn cli_tester_create_proposal(
66 test_repo: &GitTestRepo, 66 test_repo: &GitTestRepo,
67 branch_name: &str, 67 branch_name: &str,
68 prefix: &str, 68 prefix: &str,
@@ -113,7 +113,7 @@ mod when_main_is_checked_out {
113 r55.events.push(generate_test_key_1_relay_list_event()); 113 r55.events.push(generate_test_key_1_relay_list_event());
114 114
115 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 115 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
116 cli_tester_create_prs()?; 116 cli_tester_create_proposals()?;
117 117
118 let test_repo = GitTestRepo::default(); 118 let test_repo = GitTestRepo::default();
119 test_repo.populate()?; 119 test_repo.populate()?;
@@ -122,7 +122,7 @@ mod when_main_is_checked_out {
122 test_repo.checkout("main")?; 122 test_repo.checkout("main")?;
123 123
124 let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); 124 let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]);
125 p.expect("Error: checkout a branch associated with a PR first\r\n")?; 125 p.expect("Error: checkout a branch associated with a proposal first\r\n")?;
126 p.expect_end()?; 126 p.expect_end()?;
127 127
128 for p in [51, 52, 53, 55, 56] { 128 for p in [51, 52, 53, 55, 56] {
@@ -174,7 +174,7 @@ mod when_branch_doesnt_exist {
174 r55.events.push(generate_test_key_1_relay_list_event()); 174 r55.events.push(generate_test_key_1_relay_list_event());
175 175
176 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 176 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
177 cli_tester_create_prs()?; 177 cli_tester_create_proposals()?;
178 178
179 let test_repo = GitTestRepo::default(); 179 let test_repo = GitTestRepo::default();
180 test_repo.populate()?; 180 test_repo.populate()?;
@@ -183,9 +183,9 @@ mod when_branch_doesnt_exist {
183 test_repo.checkout("random-name")?; 183 test_repo.checkout("random-name")?;
184 184
185 let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); 185 let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]);
186 p.expect("finding PR event...\r\n")?; 186 p.expect("finding proposal event...\r\n")?;
187 p.expect( 187 p.expect(
188 "Error: cannot find a PR event associated with the checked out branch name\r\n", 188 "Error: cannot find a proposal event associated with the checked out branch name\r\n",
189 )?; 189 )?;
190 190
191 p.expect_end()?; 191 p.expect_end()?;
@@ -242,7 +242,7 @@ mod when_branch_is_checked_out {
242 r55.events.push(generate_test_key_1_relay_list_event()); 242 r55.events.push(generate_test_key_1_relay_list_event());
243 243
244 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 244 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
245 cli_tester_create_prs()?; 245 cli_tester_create_proposals()?;
246 246
247 let test_repo = GitTestRepo::default(); 247 let test_repo = GitTestRepo::default();
248 test_repo.populate()?; 248 test_repo.populate()?;
@@ -250,8 +250,8 @@ mod when_branch_is_checked_out {
250 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; 250 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?;
251 251
252 let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); 252 let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]);
253 p.expect("finding PR event...\r\n")?; 253 p.expect("finding proposal root event...\r\n")?;
254 p.expect("found PR event. finding commits...\r\n")?; 254 p.expect("found proposal root event. finding commits...\r\n")?;
255 p.expect("branch already up-to-date\r\n")?; 255 p.expect("branch already up-to-date\r\n")?;
256 p.expect_end()?; 256 p.expect_end()?;
257 257
@@ -304,7 +304,7 @@ mod when_branch_is_checked_out {
304 304
305 let cli_tester_handle = 305 let cli_tester_handle =
306 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { 306 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> {
307 let originating_repo = cli_tester_create_prs()?; 307 let originating_repo = cli_tester_create_proposals()?;
308 308
309 let test_repo = GitTestRepo::default(); 309 let test_repo = GitTestRepo::default();
310 test_repo.populate()?; 310 test_repo.populate()?;
@@ -356,7 +356,7 @@ mod when_branch_is_checked_out {
356 356
357 let cli_tester_handle = 357 let cli_tester_handle =
358 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { 358 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> {
359 let originating_repo = cli_tester_create_prs()?; 359 let originating_repo = cli_tester_create_proposals()?;
360 360
361 let test_repo = GitTestRepo::default(); 361 let test_repo = GitTestRepo::default();
362 test_repo.populate()?; 362 test_repo.populate()?;
@@ -364,8 +364,8 @@ mod when_branch_is_checked_out {
364 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?; 364 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?;
365 365
366 let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]); 366 let mut p = CliTester::new_from_dir(&test_repo.dir, ["pull"]);
367 p.expect("finding PR event...\r\n")?; 367 p.expect("finding proposal root event...\r\n")?;
368 p.expect("found PR event. finding commits...\r\n")?; 368 p.expect("found proposal root event. finding commits...\r\n")?;
369 p.expect("applied 1 new commits\r\n")?; 369 p.expect("applied 1 new commits\r\n")?;
370 p.expect_end()?; 370 p.expect_end()?;
371 371
@@ -397,7 +397,7 @@ mod when_branch_is_checked_out {
397 397
398 #[tokio::test] 398 #[tokio::test]
399 #[serial] 399 #[serial]
400 async fn pr_branch_tip_is_most_recent_patch() -> Result<()> { 400 async fn proposal_branch_tip_is_most_recent_patch() -> Result<()> {
401 let (originating_repo, test_repo) = prep_and_run().await?; 401 let (originating_repo, test_repo) = prep_and_run().await?;
402 assert_eq!( 402 assert_eq!(
403 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?, 403 originating_repo.get_tip_of_local_branch(FEATURE_BRANCH_NAME_1)?,
@@ -409,7 +409,7 @@ mod when_branch_is_checked_out {
409 409
410 mod when_branch_is_ahead { 410 mod when_branch_is_ahead {
411 // use super::*; 411 // use super::*;
412 // TODO latest commit in pr builds off an older commit in pr 412 // TODO latest commit in proposal builds off an older commit in proposal
413 // instead of previous. 413 // instead of previous.
414 // TODO current git user created commit on branch 414 // TODO current git user created commit on branch
415 } 415 }
diff --git a/tests/push.rs b/tests/push.rs
index 07148ae..6f3a593 100644
--- a/tests/push.rs
+++ b/tests/push.rs
@@ -7,33 +7,33 @@ static FEATURE_BRANCH_NAME_1: &str = "feature-example-t";
7static FEATURE_BRANCH_NAME_2: &str = "feature-example-f"; 7static FEATURE_BRANCH_NAME_2: &str = "feature-example-f";
8static FEATURE_BRANCH_NAME_3: &str = "feature-example-c"; 8static FEATURE_BRANCH_NAME_3: &str = "feature-example-c";
9 9
10static PR_TITLE_1: &str = "pr a"; 10static PROPOSAL_TITLE_1: &str = "proposal a";
11static PR_TITLE_2: &str = "pr b"; 11static PROPOSAL_TITLE_2: &str = "proposal b";
12static PR_TITLE_3: &str = "pr c"; 12static PROPOSAL_TITLE_3: &str = "proposal c";
13 13
14fn cli_tester_create_prs() -> Result<GitTestRepo> { 14fn cli_tester_create_proposals() -> Result<GitTestRepo> {
15 let git_repo = GitTestRepo::default(); 15 let git_repo = GitTestRepo::default();
16 git_repo.populate()?; 16 git_repo.populate()?;
17 cli_tester_create_pr( 17 cli_tester_create_proposal(
18 &git_repo, 18 &git_repo,
19 FEATURE_BRANCH_NAME_1, 19 FEATURE_BRANCH_NAME_1,
20 "a", 20 "a",
21 PR_TITLE_1, 21 PROPOSAL_TITLE_1,
22 "pr a description", 22 "proposal a description",
23 )?; 23 )?;
24 cli_tester_create_pr( 24 cli_tester_create_proposal(
25 &git_repo, 25 &git_repo,
26 FEATURE_BRANCH_NAME_2, 26 FEATURE_BRANCH_NAME_2,
27 "b", 27 "b",
28 PR_TITLE_2, 28 PROPOSAL_TITLE_2,
29 "pr b description", 29 "proposal b description",
30 )?; 30 )?;
31 cli_tester_create_pr( 31 cli_tester_create_proposal(
32 &git_repo, 32 &git_repo,
33 FEATURE_BRANCH_NAME_3, 33 FEATURE_BRANCH_NAME_3,
34 "c", 34 "c",
35 PR_TITLE_3, 35 PROPOSAL_TITLE_3,
36 "pr c description", 36 "proposal c description",
37 )?; 37 )?;
38 Ok(git_repo) 38 Ok(git_repo)
39} 39}
@@ -62,7 +62,7 @@ fn create_and_populate_branch(
62 Ok(()) 62 Ok(())
63} 63}
64 64
65fn cli_tester_create_pr( 65fn cli_tester_create_proposal(
66 test_repo: &GitTestRepo, 66 test_repo: &GitTestRepo,
67 branch_name: &str, 67 branch_name: &str,
68 prefix: &str, 68 prefix: &str,
@@ -100,13 +100,13 @@ mod when_main_is_checked_out {
100 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; 100 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?;
101 test_repo.checkout("main")?; 101 test_repo.checkout("main")?;
102 let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); 102 let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]);
103 p.expect("Error: checkout a branch associated with a PR first\r\n")?; 103 p.expect("Error: checkout a branch associated with a proposal first\r\n")?;
104 p.expect_end()?; 104 p.expect_end()?;
105 Ok(()) 105 Ok(())
106 } 106 }
107} 107}
108 108
109mod when_pr_isnt_associated_with_branch_name { 109mod when_proposal_isnt_associated_with_branch_name {
110 use super::*; 110 use super::*;
111 111
112 mod cli_prompts { 112 mod cli_prompts {
@@ -130,7 +130,7 @@ mod when_pr_isnt_associated_with_branch_name {
130 r55.events.push(generate_test_key_1_relay_list_event()); 130 r55.events.push(generate_test_key_1_relay_list_event());
131 131
132 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 132 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
133 cli_tester_create_prs()?; 133 cli_tester_create_proposals()?;
134 134
135 let test_repo = GitTestRepo::default(); 135 let test_repo = GitTestRepo::default();
136 test_repo.populate()?; 136 test_repo.populate()?;
@@ -139,9 +139,9 @@ mod when_pr_isnt_associated_with_branch_name {
139 test_repo.checkout("random-name")?; 139 test_repo.checkout("random-name")?;
140 140
141 let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); 141 let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]);
142 p.expect("finding PR event...\r\n")?; 142 p.expect("finding proposal root event...\r\n")?;
143 p.expect( 143 p.expect(
144 "Error: cannot find a PR event associated with the checked out branch name\r\n", 144 "Error: cannot find a proposal root event associated with the checked out branch name\r\n",
145 )?; 145 )?;
146 146
147 p.expect_end()?; 147 p.expect_end()?;
@@ -198,7 +198,7 @@ mod when_branch_is_checked_out {
198 r55.events.push(generate_test_key_1_relay_list_event()); 198 r55.events.push(generate_test_key_1_relay_list_event());
199 199
200 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 200 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
201 cli_tester_create_prs()?; 201 cli_tester_create_proposals()?;
202 202
203 let test_repo = GitTestRepo::default(); 203 let test_repo = GitTestRepo::default();
204 test_repo.populate()?; 204 test_repo.populate()?;
@@ -206,9 +206,9 @@ mod when_branch_is_checked_out {
206 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?; 206 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", false)?;
207 207
208 let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); 208 let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]);
209 p.expect("finding PR event...\r\n")?; 209 p.expect("finding proposal root event...\r\n")?;
210 p.expect("found PR event. finding commits...\r\n")?; 210 p.expect("found proposal root event. finding commits...\r\n")?;
211 p.expect("Error: nostr pr already up-to-date with local branch\r\n")?; 211 p.expect("Error: nostr proposal already up-to-date with local branch\r\n")?;
212 p.expect_end()?; 212 p.expect_end()?;
213 213
214 for p in [51, 52, 53, 55, 56] { 214 for p in [51, 52, 53, 55, 56] {
@@ -261,7 +261,7 @@ mod when_branch_is_checked_out {
261 r55.events.push(generate_test_key_1_relay_list_event()); 261 r55.events.push(generate_test_key_1_relay_list_event());
262 262
263 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 263 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
264 cli_tester_create_prs()?; 264 cli_tester_create_proposals()?;
265 265
266 let test_repo = GitTestRepo::default(); 266 let test_repo = GitTestRepo::default();
267 test_repo.populate()?; 267 test_repo.populate()?;
@@ -269,9 +269,9 @@ mod when_branch_is_checked_out {
269 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?; 269 create_and_populate_branch(&test_repo, FEATURE_BRANCH_NAME_1, "a", true)?;
270 270
271 let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]); 271 let mut p = CliTester::new_from_dir(&test_repo.dir, ["push"]);
272 p.expect("finding PR event...\r\n")?; 272 p.expect("finding proposal root event...\r\n")?;
273 p.expect("found PR event. finding commits...\r\n")?; 273 p.expect("found proposal root event. finding commits...\r\n")?;
274 p.expect("Error: nostr pr is ahead of local branch\r\n")?; 274 p.expect("Error: nostr proposal is ahead of local branch\r\n")?;
275 p.expect_end()?; 275 p.expect_end()?;
276 276
277 for p in [51, 52, 53, 55, 56] { 277 for p in [51, 52, 53, 55, 56] {
@@ -329,7 +329,7 @@ mod when_branch_is_checked_out {
329 329
330 let cli_tester_handle = 330 let cli_tester_handle =
331 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> { 331 std::thread::spawn(move || -> Result<(GitTestRepo, GitTestRepo)> {
332 let originating_repo = cli_tester_create_prs()?; 332 let originating_repo = cli_tester_create_proposals()?;
333 333
334 let test_repo = GitTestRepo::default(); 334 let test_repo = GitTestRepo::default();
335 test_repo.populate()?; 335 test_repo.populate()?;
@@ -350,8 +350,8 @@ mod when_branch_is_checked_out {
350 "push", 350 "push",
351 ], 351 ],
352 ); 352 );
353 p.expect("finding PR event...\r\n")?; 353 p.expect("finding proposal root event...\r\n")?;
354 p.expect("found PR event. finding commits...\r\n")?; 354 p.expect("found proposal root event. finding commits...\r\n")?;
355 p.expect( 355 p.expect(
356 "1 commits ahead. preparing to create creating patch events.\r\n", 356 "1 commits ahead. preparing to create creating patch events.\r\n",
357 )?; 357 )?;
@@ -420,7 +420,7 @@ mod when_branch_is_checked_out {
420 r55.events.push(generate_test_key_1_relay_list_event()); 420 r55.events.push(generate_test_key_1_relay_list_event());
421 421
422 let cli_tester_handle = std::thread::spawn(move || -> Result<GitTestRepo> { 422 let cli_tester_handle = std::thread::spawn(move || -> Result<GitTestRepo> {
423 cli_tester_create_prs()?; 423 cli_tester_create_proposals()?;
424 424
425 let test_repo = GitTestRepo::default(); 425 let test_repo = GitTestRepo::default();
426 test_repo.populate()?; 426 test_repo.populate()?;
diff --git a/tests/send.rs b/tests/send.rs
index 6d3e138..9c8561a 100644
--- a/tests/send.rs
+++ b/tests/send.rs
@@ -159,7 +159,7 @@ fn prep_git_repo() -> Result<GitTestRepo> {
159 Ok(test_repo) 159 Ok(test_repo)
160} 160}
161 161
162fn cli_tester_create_pr(git_repo: &GitTestRepo, include_cover_letter: bool) -> CliTester { 162fn cli_tester_create_proposal(git_repo: &GitTestRepo, include_cover_letter: bool) -> CliTester {
163 let mut args = vec![ 163 let mut args = vec![
164 "--nsec", 164 "--nsec",
165 TEST_KEY_1_NSEC, 165 TEST_KEY_1_NSEC,
@@ -199,7 +199,7 @@ fn expect_msgs_first(p: &mut CliTester, include_cover_letter: bool) -> Result<()
199 Ok(()) 199 Ok(())
200} 200}
201 201
202async fn prep_run_create_pr( 202async fn prep_run_create_proposal(
203 include_cover_letter: bool, 203 include_cover_letter: bool,
204) -> Result<( 204) -> Result<(
205 Relay<'static>, 205 Relay<'static>,
@@ -245,7 +245,7 @@ async fn prep_run_create_pr(
245 245
246 // // check relay had the right number of events 246 // // check relay had the right number of events
247 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 247 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
248 let mut p = cli_tester_create_pr(&git_repo, include_cover_letter); 248 let mut p = cli_tester_create_proposal(&git_repo, include_cover_letter);
249 p.expect_end_eventually()?; 249 p.expect_end_eventually()?;
250 for p in [51, 52, 53, 55, 56] { 250 for p in [51, 52, 53, 55, 56] {
251 relay::shutdown_relay(8000 + p)?; 251 relay::shutdown_relay(8000 + p)?;
@@ -270,8 +270,8 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
270 use super::*; 270 use super::*;
271 #[tokio::test] 271 #[tokio::test]
272 #[serial] 272 #[serial]
273 async fn only_1_pr_kind_event_sent_to_each_relay() -> Result<()> { 273 async fn only_1_cover_letter_event_sent_to_each_relay() -> Result<()> {
274 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 274 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
275 for relay in [&r53, &r55, &r56] { 275 for relay in [&r53, &r55, &r56] {
276 assert_eq!( 276 assert_eq!(
277 relay.events.iter().filter(|e| is_cover_letter(e)).count(), 277 relay.events.iter().filter(|e| is_cover_letter(e)).count(),
@@ -283,8 +283,8 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
283 283
284 #[tokio::test] 284 #[tokio::test]
285 #[serial] 285 #[serial]
286 async fn only_1_pr_kind_event_sent_to_user_relays() -> Result<()> { 286 async fn only_1_cover_letter_event_sent_to_user_relays() -> Result<()> {
287 let (_, _, r53, r55, _) = prep_run_create_pr(true).await?; 287 let (_, _, r53, r55, _) = prep_run_create_proposal(true).await?;
288 for relay in [&r53, &r55] { 288 for relay in [&r53, &r55] {
289 assert_eq!( 289 assert_eq!(
290 relay.events.iter().filter(|e| is_cover_letter(e)).count(), 290 relay.events.iter().filter(|e| is_cover_letter(e)).count(),
@@ -296,8 +296,8 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
296 296
297 #[tokio::test] 297 #[tokio::test]
298 #[serial] 298 #[serial]
299 async fn only_1_pr_kind_event_sent_to_repo_relays() -> Result<()> { 299 async fn only_1_cover_letter_event_sent_to_repo_relays() -> Result<()> {
300 let (_, _, _, r55, r56) = prep_run_create_pr(true).await?; 300 let (_, _, _, r55, r56) = prep_run_create_proposal(true).await?;
301 for relay in [&r55, &r56] { 301 for relay in [&r55, &r56] {
302 assert_eq!( 302 assert_eq!(
303 relay.events.iter().filter(|e| is_cover_letter(e)).count(), 303 relay.events.iter().filter(|e| is_cover_letter(e)).count(),
@@ -309,8 +309,8 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
309 309
310 #[tokio::test] 310 #[tokio::test]
311 #[serial] 311 #[serial]
312 async fn only_1_pr_kind_event_sent_to_fallback_relays() -> Result<()> { 312 async fn only_1_cover_letter_event_sent_to_fallback_relays() -> Result<()> {
313 let (r51, r52, _, _, _) = prep_run_create_pr(true).await?; 313 let (r51, r52, _, _, _) = prep_run_create_proposal(true).await?;
314 for relay in [&r51, &r52] { 314 for relay in [&r51, &r52] {
315 assert_eq!( 315 assert_eq!(
316 relay.events.iter().filter(|e| is_cover_letter(e)).count(), 316 relay.events.iter().filter(|e| is_cover_letter(e)).count(),
@@ -323,7 +323,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
323 #[tokio::test] 323 #[tokio::test]
324 #[serial] 324 #[serial]
325 async fn only_2_patch_kind_events_sent_to_each_relay() -> Result<()> { 325 async fn only_2_patch_kind_events_sent_to_each_relay() -> Result<()> {
326 let (r51, r52, r53, r55, r56) = prep_run_create_pr(true).await?; 326 let (r51, r52, r53, r55, r56) = prep_run_create_proposal(true).await?;
327 for relay in [&r51, &r52, &r53, &r55, &r56] { 327 for relay in [&r51, &r52, &r53, &r55, &r56] {
328 assert_eq!(relay.events.iter().filter(|e| is_patch(e)).count(), 2,); 328 assert_eq!(relay.events.iter().filter(|e| is_patch(e)).count(), 2,);
329 } 329 }
@@ -334,7 +334,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
334 #[serial] 334 #[serial]
335 async fn patch_content_contains_patch_in_email_format_with_patch_series_numbers() -> Result<()> 335 async fn patch_content_contains_patch_in_email_format_with_patch_series_numbers() -> Result<()>
336 { 336 {
337 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 337 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
338 for relay in [&r53, &r55, &r56] { 338 for relay in [&r53, &r55, &r56] {
339 let patch_events: Vec<&nostr::Event> = 339 let patch_events: Vec<&nostr::Event> =
340 relay.events.iter().filter(|e| is_patch(e)).collect(); 340 relay.events.iter().filter(|e| is_patch(e)).collect();
@@ -395,19 +395,19 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
395 Ok(()) 395 Ok(())
396 } 396 }
397 397
398 mod pr_tags { 398 mod cover_letter_tags {
399 use super::*; 399 use super::*;
400 400
401 #[tokio::test] 401 #[tokio::test]
402 #[serial] 402 #[serial]
403 async fn root_commit_as_r() -> Result<()> { 403 async fn root_commit_as_r() -> Result<()> {
404 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 404 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
405 for relay in [&r53, &r55, &r56] { 405 for relay in [&r53, &r55, &r56] {
406 let pr_event: &nostr::Event = 406 let cover_letter_event: &nostr::Event =
407 relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); 407 relay.events.iter().find(|e| is_cover_letter(e)).unwrap();
408 408
409 assert_eq!( 409 assert_eq!(
410 pr_event 410 cover_letter_event
411 .iter_tags() 411 .iter_tags()
412 .find(|t| t.as_vec()[0].eq("r")) 412 .find(|t| t.as_vec()[0].eq("r"))
413 .unwrap() 413 .unwrap()
@@ -421,11 +421,11 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
421 #[tokio::test] 421 #[tokio::test]
422 #[serial] 422 #[serial]
423 async fn a_tag_for_repo_event() -> Result<()> { 423 async fn a_tag_for_repo_event() -> Result<()> {
424 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 424 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
425 for relay in [&r53, &r55, &r56] { 425 for relay in [&r53, &r55, &r56] {
426 let pr_event: &nostr::Event = 426 let cover_letter_event: &nostr::Event =
427 relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); 427 relay.events.iter().find(|e| is_cover_letter(e)).unwrap();
428 assert!(pr_event.iter_tags().any(|t| t.as_vec()[0].eq("a") 428 assert!(cover_letter_event.iter_tags().any(|t| t.as_vec()[0].eq("a")
429 && t.as_vec()[1].eq(&format!( 429 && t.as_vec()[1].eq(&format!(
430 "{REPOSITORY_KIND}:{TEST_KEY_1_PUBKEY_HEX}:{}", 430 "{REPOSITORY_KIND}:{TEST_KEY_1_PUBKEY_HEX}:{}",
431 generate_repo_ref_event().identifier().unwrap() 431 generate_repo_ref_event().identifier().unwrap()
@@ -443,13 +443,13 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
443 .unwrap() 443 .unwrap()
444 .as_vec() 444 .as_vec()
445 .clone()[1..]; 445 .clone()[1..];
446 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 446 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
447 for relay in [&r53, &r55, &r56] { 447 for relay in [&r53, &r55, &r56] {
448 for m in maintainers { 448 for m in maintainers {
449 let pr_event: &nostr::Event = 449 let cover_letter_event: &nostr::Event =
450 relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); 450 relay.events.iter().find(|e| is_cover_letter(e)).unwrap();
451 assert!( 451 assert!(
452 pr_event 452 cover_letter_event
453 .iter_tags() 453 .iter_tags()
454 .any(|t| { t.as_vec()[0].eq("p") && t.as_vec()[1].eq(m) }) 454 .any(|t| { t.as_vec()[0].eq("p") && t.as_vec()[1].eq(m) })
455 ); 455 );
@@ -461,12 +461,12 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
461 #[tokio::test] 461 #[tokio::test]
462 #[serial] 462 #[serial]
463 async fn t_tag_cover_letter() -> Result<()> { 463 async fn t_tag_cover_letter() -> Result<()> {
464 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 464 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
465 for relay in [&r53, &r55, &r56] { 465 for relay in [&r53, &r55, &r56] {
466 let pr_event: &nostr::Event = 466 let cover_letter_event: &nostr::Event =
467 relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); 467 relay.events.iter().find(|e| is_cover_letter(e)).unwrap();
468 assert!( 468 assert!(
469 pr_event 469 cover_letter_event
470 .iter_tags() 470 .iter_tags()
471 .any(|t| { t.as_vec()[0].eq("t") && t.as_vec()[1].eq(&"cover-letter") }) 471 .any(|t| { t.as_vec()[0].eq("t") && t.as_vec()[1].eq(&"cover-letter") })
472 ); 472 );
@@ -477,12 +477,12 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
477 #[tokio::test] 477 #[tokio::test]
478 #[serial] 478 #[serial]
479 async fn t_tag_root() -> Result<()> { 479 async fn t_tag_root() -> Result<()> {
480 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 480 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
481 for relay in [&r53, &r55, &r56] { 481 for relay in [&r53, &r55, &r56] {
482 let pr_event: &nostr::Event = 482 let cover_letter_event: &nostr::Event =
483 relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); 483 relay.events.iter().find(|e| is_cover_letter(e)).unwrap();
484 assert!( 484 assert!(
485 pr_event 485 cover_letter_event
486 .iter_tags() 486 .iter_tags()
487 .any(|t| { t.as_vec()[0].eq("t") && t.as_vec()[1].eq(&"root") }) 487 .any(|t| { t.as_vec()[0].eq("t") && t.as_vec()[1].eq(&"root") })
488 ); 488 );
@@ -493,14 +493,14 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
493 #[tokio::test] 493 #[tokio::test]
494 #[serial] 494 #[serial]
495 async fn pr_tags_branch_name() -> Result<()> { 495 async fn pr_tags_branch_name() -> Result<()> {
496 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 496 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
497 for relay in [&r53, &r55, &r56] { 497 for relay in [&r53, &r55, &r56] {
498 let pr_event: &nostr::Event = 498 let cover_letter_event: &nostr::Event =
499 relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); 499 relay.events.iter().find(|e| is_cover_letter(e)).unwrap();
500 500
501 // branch-name tag 501 // branch-name tag
502 assert_eq!( 502 assert_eq!(
503 pr_event 503 cover_letter_event
504 .iter_tags() 504 .iter_tags()
505 .find(|t| t.as_vec()[0].eq("branch-name")) 505 .find(|t| t.as_vec()[0].eq("branch-name"))
506 .unwrap() 506 .unwrap()
@@ -516,7 +516,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
516 use super::*; 516 use super::*;
517 517
518 async fn prep() -> Result<nostr::Event> { 518 async fn prep() -> Result<nostr::Event> {
519 let (_, _, r53, _, _) = prep_run_create_pr(true).await?; 519 let (_, _, r53, _, _) = prep_run_create_proposal(true).await?;
520 Ok(r53.events.iter().find(|e| is_patch(e)).unwrap().clone()) 520 Ok(r53.events.iter().find(|e| is_patch(e)).unwrap().clone())
521 } 521 }
522 522
@@ -649,14 +649,14 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
649 649
650 #[tokio::test] 650 #[tokio::test]
651 #[serial] 651 #[serial]
652 async fn patch_tags_pr_event_as_root() -> Result<()> { 652 async fn patch_tags_cover_letter_event_as_root() -> Result<()> {
653 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 653 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
654 for relay in [&r53, &r55, &r56] { 654 for relay in [&r53, &r55, &r56] {
655 let patch_events: Vec<&nostr::Event> = 655 let patch_events: Vec<&nostr::Event> =
656 relay.events.iter().filter(|e| is_patch(e)).collect(); 656 relay.events.iter().filter(|e| is_patch(e)).collect();
657 657
658 let most_recent_patch = patch_events[0]; 658 let most_recent_patch = patch_events[0];
659 let pr_event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap(); 659 let cover_letter_event = relay.events.iter().find(|e| is_cover_letter(e)).unwrap();
660 660
661 let root_event_tag = most_recent_patch 661 let root_event_tag = most_recent_patch
662 .tags 662 .tags
@@ -666,7 +666,10 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
666 }) 666 })
667 .unwrap(); 667 .unwrap();
668 668
669 assert_eq!(root_event_tag.as_vec()[1], pr_event.id.to_string()); 669 assert_eq!(
670 root_event_tag.as_vec()[1],
671 cover_letter_event.id.to_string()
672 );
670 } 673 }
671 Ok(()) 674 Ok(())
672 } 675 }
@@ -674,7 +677,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
674 #[tokio::test] 677 #[tokio::test]
675 #[serial] 678 #[serial]
676 async fn second_patch_tags_first_with_reply() -> Result<()> { 679 async fn second_patch_tags_first_with_reply() -> Result<()> {
677 let (_, _, r53, r55, r56) = prep_run_create_pr(true).await?; 680 let (_, _, r53, r55, r56) = prep_run_create_proposal(true).await?;
678 for relay in [&r53, &r55, &r56] { 681 for relay in [&r53, &r55, &r56] {
679 let patch_events = relay 682 let patch_events = relay
680 .events 683 .events
@@ -749,7 +752,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
749 752
750 // // check relay had the right number of events 753 // // check relay had the right number of events
751 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 754 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
752 let mut p = cli_tester_create_pr(&git_repo, true); 755 let mut p = cli_tester_create_proposal(&git_repo, true);
753 expect_msgs_first(&mut p, true)?; 756 expect_msgs_first(&mut p, true)?;
754 relay::expect_send_with_progress( 757 relay::expect_send_with_progress(
755 &mut p, 758 &mut p,
@@ -840,7 +843,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
840 843
841 // // check relay had the right number of events 844 // // check relay had the right number of events
842 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 845 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
843 let mut p = cli_tester_create_pr(&git_repo, true); 846 let mut p = cli_tester_create_proposal(&git_repo, true);
844 p.expect_end_eventually()?; 847 p.expect_end_eventually()?;
845 for p in [51, 52, 53, 55, 56] { 848 for p in [51, 52, 53, 55, 56] {
846 relay::shutdown_relay(8000 + p)?; 849 relay::shutdown_relay(8000 + p)?;
@@ -919,7 +922,7 @@ mod sends_cover_letter_and_2_patches_to_3_relays {
919 922
920 // // check relay had the right number of events 923 // // check relay had the right number of events
921 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 924 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
922 let mut p = cli_tester_create_pr(&git_repo, true); 925 let mut p = cli_tester_create_proposal(&git_repo, true);
923 expect_msgs_first(&mut p, true)?; 926 expect_msgs_first(&mut p, true)?;
924 // p.expect_end_with("bla")?; 927 // p.expect_end_with("bla")?;
925 relay::expect_send_with_progress( 928 relay::expect_send_with_progress(
@@ -1011,7 +1014,7 @@ mod sends_2_patches_without_cover_letter {
1011 1014
1012 // // check relay had the right number of events 1015 // // check relay had the right number of events
1013 let cli_tester_handle = std::thread::spawn(move || -> Result<()> { 1016 let cli_tester_handle = std::thread::spawn(move || -> Result<()> {
1014 let mut p = cli_tester_create_pr(&git_repo, false); 1017 let mut p = cli_tester_create_proposal(&git_repo, false);
1015 1018
1016 expect_msgs_first(&mut p, false)?; 1019 expect_msgs_first(&mut p, false)?;
1017 relay::expect_send_with_progress( 1020 relay::expect_send_with_progress(
@@ -1055,7 +1058,7 @@ mod sends_2_patches_without_cover_letter {
1055 #[tokio::test] 1058 #[tokio::test]
1056 #[serial] 1059 #[serial]
1057 async fn no_cover_letter_event() -> Result<()> { 1060 async fn no_cover_letter_event() -> Result<()> {
1058 let (_, _, r53, r55, r56) = prep_run_create_pr(false).await?; 1061 let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?;
1059 for relay in [&r53, &r55, &r56] { 1062 for relay in [&r53, &r55, &r56] {
1060 assert_eq!( 1063 assert_eq!(
1061 relay.events.iter().filter(|e| is_cover_letter(e)).count(), 1064 relay.events.iter().filter(|e| is_cover_letter(e)).count(),
@@ -1068,7 +1071,7 @@ mod sends_2_patches_without_cover_letter {
1068 #[tokio::test] 1071 #[tokio::test]
1069 #[serial] 1072 #[serial]
1070 async fn two_patch_events() -> Result<()> { 1073 async fn two_patch_events() -> Result<()> {
1071 let (_, _, r53, r55, r56) = prep_run_create_pr(false).await?; 1074 let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?;
1072 for relay in [&r53, &r55, &r56] { 1075 for relay in [&r53, &r55, &r56] {
1073 assert_eq!(relay.events.iter().filter(|e| is_patch(e)).count(), 2); 1076 assert_eq!(relay.events.iter().filter(|e| is_patch(e)).count(), 2);
1074 } 1077 }
@@ -1079,7 +1082,7 @@ mod sends_2_patches_without_cover_letter {
1079 #[serial] 1082 #[serial]
1080 // TODO check this is the ancestor 1083 // TODO check this is the ancestor
1081 async fn first_patch_with_root_t_tag() -> Result<()> { 1084 async fn first_patch_with_root_t_tag() -> Result<()> {
1082 let (_, _, r53, r55, r56) = prep_run_create_pr(false).await?; 1085 let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?;
1083 for relay in [&r53, &r55, &r56] { 1086 for relay in [&r53, &r55, &r56] {
1084 let patch_events = relay 1087 let patch_events = relay
1085 .events 1088 .events
@@ -1106,7 +1109,7 @@ mod sends_2_patches_without_cover_letter {
1106 #[tokio::test] 1109 #[tokio::test]
1107 #[serial] 1110 #[serial]
1108 async fn second_patch_lists_first_as_root() -> Result<()> { 1111 async fn second_patch_lists_first_as_root() -> Result<()> {
1109 let (_, _, r53, r55, r56) = prep_run_create_pr(false).await?; 1112 let (_, _, r53, r55, r56) = prep_run_create_proposal(false).await?;
1110 for relay in [&r53, &r55, &r56] { 1113 for relay in [&r53, &r55, &r56] {
1111 let patch_events = relay 1114 let patch_events = relay
1112 .events 1115 .events