upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/git_remote_nostr/push.rs36
-rw-r--r--src/bin/git_remote_nostr/utils.rs13
-rw-r--r--src/bin/ngit/sub_commands/list.rs13
-rw-r--r--src/bin/ngit/sub_commands/send.rs7
-rw-r--r--src/lib/client.rs135
-rw-r--r--src/lib/git/identify_ahead_behind.rs8
-rw-r--r--src/lib/git/mod.rs94
-rw-r--r--src/lib/git/nostr_url.rs8
-rw-r--r--src/lib/git_events.rs16
-rw-r--r--src/lib/login/fresh.rs8
-rw-r--r--src/lib/login/mod.rs14
-rw-r--r--src/lib/repo_ref.rs13
-rw-r--r--src/lib/repo_state.rs7
13 files changed, 212 insertions, 160 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index 04fc4d8..9ff8af0 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -1049,10 +1049,13 @@ async fn get_merged_status_events(
1049 let (ahead, _) = 1049 let (ahead, _) =
1050 git_repo.get_commits_ahead_behind(&tip_of_remote_branch, &tip_of_pushed_branch)?; 1050 git_repo.get_commits_ahead_behind(&tip_of_remote_branch, &tip_of_pushed_branch)?;
1051 1051
1052 let commit_events = get_events_from_local_cache(git_repo.get_path()?, vec![ 1052 let commit_events = get_events_from_local_cache(
1053 nostr::Filter::default().kind(nostr::Kind::GitPatch), 1053 git_repo.get_path()?,
1054 // TODO: limit by repo_ref 1054 vec![
1055 ]) 1055 nostr::Filter::default().kind(nostr::Kind::GitPatch),
1056 // TODO: limit by repo_ref
1057 ],
1058 )
1056 .await?; 1059 .await?;
1057 1060
1058 let merged_proposals_info = 1061 let merged_proposals_info =
@@ -1129,9 +1132,12 @@ async fn get_merged_proposals_info(
1129 proposals.entry(proposal_id).or_default(); 1132 proposals.entry(proposal_id).or_default();
1130 // ignore revisions without all the merged commits 1133 // ignore revisions without all the merged commits
1131 if entry_revision_id == &revision_id { 1134 if entry_revision_id == &revision_id {
1132 merged_patches.insert(*commit_hash, MergedPRCommitType::PatchCommit { 1135 merged_patches.insert(
1133 event_id: patch_event.id, 1136 *commit_hash,
1134 }); 1137 MergedPRCommitType::PatchCommit {
1138 event_id: patch_event.id,
1139 },
1140 );
1135 } 1141 }
1136 } 1142 }
1137 } 1143 }
@@ -1156,9 +1162,12 @@ async fn get_merged_proposals_info(
1156 proposals.entry(proposal_id).or_default(); 1162 proposals.entry(proposal_id).or_default();
1157 // ignore revisions without all the applied commits 1163 // ignore revisions without all the applied commits
1158 if entry_revision_id == &revision_id { 1164 if entry_revision_id == &revision_id {
1159 merged_patches.insert(*commit_hash, MergedPRCommitType::PatchApplied { 1165 merged_patches.insert(
1160 event_id: patch_event.id, 1166 *commit_hash,
1161 }); 1167 MergedPRCommitType::PatchApplied {
1168 event_id: patch_event.id,
1169 },
1170 );
1162 } 1171 }
1163 } 1172 }
1164 } 1173 }
@@ -1405,9 +1414,10 @@ async fn get_proposal_and_revision_root_from_patch(
1405 .clone(), 1414 .clone(),
1406 )?; 1415 )?;
1407 1416
1408 get_events_from_local_cache(git_repo.get_path()?, vec![ 1417 get_events_from_local_cache(
1409 nostr::Filter::default().id(proposal_or_revision_id), 1418 git_repo.get_path()?,
1410 ]) 1419 vec![nostr::Filter::default().id(proposal_or_revision_id)],
1420 )
1411 .await? 1421 .await?
1412 .first() 1422 .first()
1413 .unwrap() 1423 .unwrap()
diff --git a/src/bin/git_remote_nostr/utils.rs b/src/bin/git_remote_nostr/utils.rs
index f7e688e..dc75872 100644
--- a/src/bin/git_remote_nostr/utils.rs
+++ b/src/bin/git_remote_nostr/utils.rs
@@ -108,11 +108,14 @@ pub async fn get_open_or_draft_proposals(
108 .collect(); 108 .collect();
109 109
110 let statuses: Vec<nostr::Event> = { 110 let statuses: Vec<nostr::Event> = {
111 let mut statuses = get_events_from_local_cache(git_repo_path, vec![ 111 let mut statuses = get_events_from_local_cache(
112 nostr::Filter::default() 112 git_repo_path,
113 .kinds(status_kinds().clone()) 113 vec![
114 .events(proposals.iter().map(|e| e.id)), 114 nostr::Filter::default()
115 ]) 115 .kinds(status_kinds().clone())
116 .events(proposals.iter().map(|e| e.id)),
117 ],
118 )
116 .await?; 119 .await?;
117 statuses.sort_by_key(|e| e.created_at); 120 statuses.sort_by_key(|e| e.created_at);
118 statuses.reverse(); 121 statuses.reverse();
diff --git a/src/bin/ngit/sub_commands/list.rs b/src/bin/ngit/sub_commands/list.rs
index 2c91e66..0330be1 100644
--- a/src/bin/ngit/sub_commands/list.rs
+++ b/src/bin/ngit/sub_commands/list.rs
@@ -49,11 +49,14 @@ pub async fn launch() -> Result<()> {
49 } 49 }
50 50
51 let statuses: Vec<nostr::Event> = { 51 let statuses: Vec<nostr::Event> = {
52 let mut statuses = get_events_from_local_cache(git_repo_path, vec![ 52 let mut statuses = get_events_from_local_cache(
53 nostr::Filter::default() 53 git_repo_path,
54 .kinds(status_kinds().clone()) 54 vec![
55 .events(proposals_and_revisions.iter().map(|e| e.id)), 55 nostr::Filter::default()
56 ]) 56 .kinds(status_kinds().clone())
57 .events(proposals_and_revisions.iter().map(|e| e.id)),
58 ],
59 )
57 .await?; 60 .await?;
58 statuses.sort_by_key(|e| e.created_at); 61 statuses.sort_by_key(|e| e.created_at);
59 statuses.reverse(); 62 statuses.reverse();
diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs
index 5a5acc8..c84e339 100644
--- a/src/bin/ngit/sub_commands/send.rs
+++ b/src/bin/ngit/sub_commands/send.rs
@@ -378,9 +378,10 @@ async fn get_root_proposal_id_and_mentions_from_in_reply_to(
378 public_key: _, 378 public_key: _,
379 uppercase: false, 379 uppercase: false,
380 }) => { 380 }) => {
381 let events = get_events_from_local_cache(git_repo_path, vec![ 381 let events = get_events_from_local_cache(
382 nostr::Filter::new().id(*event_id), 382 git_repo_path,
383 ]) 383 vec![nostr::Filter::new().id(*event_id)],
384 )
384 .await?; 385 .await?;
385 386
386 if let Some(first) = events.iter().find(|e| e.id.eq(event_id)) { 387 if let Some(first) = events.iter().find(|e| e.id.eq(event_id)) {
diff --git a/src/lib/client.rs b/src/lib/client.rs
index 445bf77..9253022 100644
--- a/src/lib/client.rs
+++ b/src/lib/client.rs
@@ -794,8 +794,7 @@ pub async fn sign_event(
794 if signer.backend() == SignerBackend::NostrConnect { 794 if signer.backend() == SignerBackend::NostrConnect {
795 let term = console::Term::stderr(); 795 let term = console::Term::stderr();
796 term.write_line(&format!( 796 term.write_line(&format!(
797 "signing event ({}) with remote signer...", 797 "signing event ({description}) with remote signer..."
798 description
799 ))?; 798 ))?;
800 let event = signer 799 let event = signer
801 .sign_event(event_builder.build(signer.get_public_key().await?)) 800 .sign_event(event_builder.build(signer.get_public_key().await?))
@@ -1104,16 +1103,18 @@ pub async fn get_state_from_cache(
1104) -> Result<RepoState> { 1103) -> Result<RepoState> {
1105 if let Some(git_repo_path) = git_repo_path { 1104 if let Some(git_repo_path) = git_repo_path {
1106 RepoState::try_from( 1105 RepoState::try_from(
1107 get_events_from_local_cache(git_repo_path, vec![get_filter_state_events( 1106 get_events_from_local_cache(
1108 &repo_ref.coordinates(), 1107 git_repo_path,
1109 )]) 1108 vec![get_filter_state_events(&repo_ref.coordinates())],
1109 )
1110 .await?, 1110 .await?,
1111 ) 1111 )
1112 } else { 1112 } else {
1113 RepoState::try_from( 1113 RepoState::try_from(
1114 get_event_from_global_cache(git_repo_path, vec![get_filter_state_events( 1114 get_event_from_global_cache(
1115 &repo_ref.coordinates(), 1115 git_repo_path,
1116 )]) 1116 vec![get_filter_state_events(&repo_ref.coordinates())],
1117 )
1117 .await?, 1118 .await?,
1118 ) 1119 )
1119 } 1120 }
@@ -1179,17 +1180,20 @@ async fn create_relays_request(
1179 } 1180 }
1180 1181
1181 if let Some(git_repo_path) = git_repo_path { 1182 if let Some(git_repo_path) = git_repo_path {
1182 for event in &get_events_from_local_cache(git_repo_path, vec![ 1183 for event in &get_events_from_local_cache(
1183 nostr::Filter::default() 1184 git_repo_path,
1184 .kinds(vec![Kind::GitPatch]) 1185 vec![
1185 .custom_tags( 1186 nostr::Filter::default()
1186 SingleLetterTag::lowercase(nostr_sdk::Alphabet::A), 1187 .kinds(vec![Kind::GitPatch])
1187 repo_coordinates_without_relays 1188 .custom_tags(
1188 .iter() 1189 SingleLetterTag::lowercase(nostr_sdk::Alphabet::A),
1189 .map(|c| c.coordinate.to_string()) 1190 repo_coordinates_without_relays
1190 .collect::<Vec<String>>(), 1191 .iter()
1191 ), 1192 .map(|c| c.coordinate.to_string())
1192 ]) 1193 .collect::<Vec<String>>(),
1194 ),
1195 ],
1196 )
1193 .await? 1197 .await?
1194 { 1198 {
1195 if event_is_patch_set_root(event) || event_is_revision_root(event) { 1199 if event_is_patch_set_root(event) || event_is_revision_root(event) {
@@ -1199,11 +1203,11 @@ async fn create_relays_request(
1199 } 1203 }
1200 } 1204 }
1201 1205
1202 let profile_events = 1206 let profile_events = get_event_from_global_cache(
1203 get_event_from_global_cache(git_repo_path, vec![get_filter_contributor_profiles( 1207 git_repo_path,
1204 contributors.clone(), 1208 vec![get_filter_contributor_profiles(contributors.clone())],
1205 )]) 1209 )
1206 .await?; 1210 .await?;
1207 for c in &contributors { 1211 for c in &contributors {
1208 if let Some(event) = profile_events 1212 if let Some(event) = profile_events
1209 .iter() 1213 .iter()
@@ -1769,17 +1773,20 @@ pub async fn get_proposals_and_revisions_from_cache(
1769 git_repo_path: &Path, 1773 git_repo_path: &Path,
1770 repo_coordinates: HashSet<Nip19Coordinate>, 1774 repo_coordinates: HashSet<Nip19Coordinate>,
1771) -> Result<Vec<nostr::Event>> { 1775) -> Result<Vec<nostr::Event>> {
1772 let mut proposals = get_events_from_local_cache(git_repo_path, vec![ 1776 let mut proposals = get_events_from_local_cache(
1773 nostr::Filter::default() 1777 git_repo_path,
1774 .kind(nostr::Kind::GitPatch) 1778 vec![
1775 .custom_tags( 1779 nostr::Filter::default()
1776 nostr::SingleLetterTag::lowercase(nostr_sdk::Alphabet::A), 1780 .kind(nostr::Kind::GitPatch)
1777 repo_coordinates 1781 .custom_tags(
1778 .iter() 1782 nostr::SingleLetterTag::lowercase(nostr_sdk::Alphabet::A),
1779 .map(|c| c.coordinate.to_string()) 1783 repo_coordinates
1780 .collect::<Vec<String>>(), 1784 .iter()
1781 ), 1785 .map(|c| c.coordinate.to_string())
1782 ]) 1786 .collect::<Vec<String>>(),
1787 ),
1788 ],
1789 )
1783 .await? 1790 .await?
1784 .iter() 1791 .iter()
1785 .filter(|e| event_is_patch_set_root(e)) 1792 .filter(|e| event_is_patch_set_root(e))
@@ -1795,23 +1802,29 @@ pub async fn get_all_proposal_patch_events_from_cache(
1795 repo_ref: &RepoRef, 1802 repo_ref: &RepoRef,
1796 proposal_id: &nostr::EventId, 1803 proposal_id: &nostr::EventId,
1797) -> Result<Vec<nostr::Event>> { 1804) -> Result<Vec<nostr::Event>> {
1798 let mut commit_events = get_events_from_local_cache(git_repo_path, vec![ 1805 let mut commit_events = get_events_from_local_cache(
1799 nostr::Filter::default() 1806 git_repo_path,
1800 .kind(nostr::Kind::GitPatch) 1807 vec![
1801 .event(*proposal_id), 1808 nostr::Filter::default()
1802 nostr::Filter::default() 1809 .kind(nostr::Kind::GitPatch)
1803 .kind(nostr::Kind::GitPatch) 1810 .event(*proposal_id),
1804 .id(*proposal_id), 1811 nostr::Filter::default()
1805 ]) 1812 .kind(nostr::Kind::GitPatch)
1813 .id(*proposal_id),
1814 ],
1815 )
1806 .await?; 1816 .await?;
1807 1817
1808 let permissioned_users: HashSet<PublicKey> = [repo_ref.maintainers.clone(), vec![ 1818 let permissioned_users: HashSet<PublicKey> = [
1809 commit_events 1819 repo_ref.maintainers.clone(),
1810 .iter() 1820 vec![
1811 .find(|e| e.id.eq(proposal_id)) 1821 commit_events
1812 .context("proposal not in cache")? 1822 .iter()
1813 .pubkey, 1823 .find(|e| e.id.eq(proposal_id))
1814 ]] 1824 .context("proposal not in cache")?
1825 .pubkey,
1826 ],
1827 ]
1815 .concat() 1828 .concat()
1816 .iter() 1829 .iter()
1817 .copied() 1830 .copied()
@@ -1825,12 +1838,15 @@ pub async fn get_all_proposal_patch_events_from_cache(
1825 .collect(); 1838 .collect();
1826 1839
1827 if !revision_roots.is_empty() { 1840 if !revision_roots.is_empty() {
1828 for event in get_events_from_local_cache(git_repo_path, vec![ 1841 for event in get_events_from_local_cache(
1829 nostr::Filter::default() 1842 git_repo_path,
1830 .kind(nostr::Kind::GitPatch) 1843 vec![
1831 .events(revision_roots) 1844 nostr::Filter::default()
1832 .authors(permissioned_users.clone()), 1845 .kind(nostr::Kind::GitPatch)
1833 ]) 1846 .events(revision_roots)
1847 .authors(permissioned_users.clone()),
1848 ],
1849 )
1834 .await? 1850 .await?
1835 { 1851 {
1836 commit_events.push(event); 1852 commit_events.push(event);
@@ -1845,9 +1861,10 @@ pub async fn get_all_proposal_patch_events_from_cache(
1845} 1861}
1846 1862
1847pub async fn get_event_from_cache_by_id(git_repo: &Repo, event_id: &EventId) -> Result<Event> { 1863pub async fn get_event_from_cache_by_id(git_repo: &Repo, event_id: &EventId) -> Result<Event> {
1848 Ok(get_events_from_local_cache(git_repo.get_path()?, vec![ 1864 Ok(get_events_from_local_cache(
1849 nostr::Filter::default().id(*event_id), 1865 git_repo.get_path()?,
1850 ]) 1866 vec![nostr::Filter::default().id(*event_id)],
1867 )
1851 .await? 1868 .await?
1852 .first() 1869 .first()
1853 .context("failed to find event in cache")? 1870 .context("failed to find event in cache")?
diff --git a/src/lib/git/identify_ahead_behind.rs b/src/lib/git/identify_ahead_behind.rs
index baea687..d736522 100644
--- a/src/lib/git/identify_ahead_behind.rs
+++ b/src/lib/git/identify_ahead_behind.rs
@@ -184,10 +184,10 @@ mod tests {
184 identify_ahead_behind(&git_repo, &Some("feature".to_string()), &None)?; 184 identify_ahead_behind(&git_repo, &Some("feature".to_string()), &None)?;
185 185
186 assert_eq!(from_branch, "feature"); 186 assert_eq!(from_branch, "feature");
187 assert_eq!(ahead, vec![ 187 assert_eq!(
188 oid_to_sha1(&feature_oid), 188 ahead,
189 oid_to_sha1(&dev_oid_first) 189 vec![oid_to_sha1(&feature_oid), oid_to_sha1(&dev_oid_first)]
190 ]); 190 );
191 assert_eq!(to_branch, "main"); 191 assert_eq!(to_branch, "main");
192 assert_eq!(behind, vec![]); 192 assert_eq!(behind, vec![]);
193 193
diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs
index 0256457..d4bf2f5 100644
--- a/src/lib/git/mod.rs
+++ b/src/lib/git/mod.rs
@@ -888,7 +888,7 @@ pub fn save_git_config_item(git_repo: &Option<&Repo>, item: &str, value: &str) -
888 git2::Config::open_default()? 888 git2::Config::open_default()?
889 .open_global()? 889 .open_global()?
890 .set_str(item, value) 890 .set_str(item, value)
891 .context(format!("failed to set global git config item {}", item)) 891 .context(format!("failed to set global git config item {item}"))
892 } 892 }
893} 893}
894 894
@@ -901,10 +901,7 @@ pub fn remove_git_config_item(git_repo: &Option<&Repo>, item: &str) -> Result<bo
901 git2::Config::open_default()? 901 git2::Config::open_default()?
902 .open_global()? 902 .open_global()?
903 .remove(item) 903 .remove(item)
904 .context(format!( 904 .context(format!("failed to remove existing git config item {item}"))?;
905 "failed to remove existing git config item {}",
906 item
907 ))?;
908 Ok(true) 905 Ok(true)
909 } 906 }
910} 907}
@@ -1271,7 +1268,7 @@ mod tests {
1271 +some content1\n\\ \ 1268 +some content1\n\\ \
1272 No newline at end of file\n\ 1269 No newline at end of file\n\
1273 --\n\ 1270 --\n\
1274 libgit2 1.9.0\n\ 1271 libgit2 1.9.1\n\
1275 \n\ 1272 \n\
1276 ", 1273 ",
1277 git_repo.make_patch_from_commit(&oid_to_sha1(&oid), &None)?, 1274 git_repo.make_patch_from_commit(&oid_to_sha1(&oid), &None)?,
@@ -1307,7 +1304,7 @@ mod tests {
1307 +some content1\n\\ \ 1304 +some content1\n\\ \
1308 No newline at end of file\n\ 1305 No newline at end of file\n\
1309 --\n\ 1306 --\n\
1310 libgit2 1.9.0\n\ 1307 libgit2 1.9.1\n\
1311 \n\ 1308 \n\
1312 ", 1309 ",
1313 git_repo.make_patch_from_commit(&oid_to_sha1(&oid), &Some((3, 5)))?, 1310 git_repo.make_patch_from_commit(&oid_to_sha1(&oid), &Some((3, 5)))?,
@@ -1493,10 +1490,10 @@ mod tests {
1493 &oid_to_sha1(&feature_oid), 1490 &oid_to_sha1(&feature_oid),
1494 )?; 1491 )?;
1495 assert_eq!(ahead, vec![]); 1492 assert_eq!(ahead, vec![]);
1496 assert_eq!(behind, vec![ 1493 assert_eq!(
1497 oid_to_sha1(&behind_2_oid), 1494 behind,
1498 oid_to_sha1(&behind_1_oid), 1495 vec![oid_to_sha1(&behind_2_oid), oid_to_sha1(&behind_1_oid),],
1499 ],); 1496 );
1500 Ok(()) 1497 Ok(())
1501 } 1498 }
1502 1499
@@ -1518,10 +1515,10 @@ mod tests {
1518 &oid_to_sha1(&main_oid), 1515 &oid_to_sha1(&main_oid),
1519 &oid_to_sha1(&ahead_2_oid), 1516 &oid_to_sha1(&ahead_2_oid),
1520 )?; 1517 )?;
1521 assert_eq!(ahead, vec![ 1518 assert_eq!(
1522 oid_to_sha1(&ahead_2_oid), 1519 ahead,
1523 oid_to_sha1(&ahead_1_oid), 1520 vec![oid_to_sha1(&ahead_2_oid), oid_to_sha1(&ahead_1_oid),],
1524 ],); 1521 );
1525 assert_eq!(behind, vec![]); 1522 assert_eq!(behind, vec![]);
1526 Ok(()) 1523 Ok(())
1527 } 1524 }
@@ -1550,14 +1547,14 @@ mod tests {
1550 &oid_to_sha1(&behind_2_oid), 1547 &oid_to_sha1(&behind_2_oid),
1551 &oid_to_sha1(&ahead_2_oid), 1548 &oid_to_sha1(&ahead_2_oid),
1552 )?; 1549 )?;
1553 assert_eq!(ahead, vec![ 1550 assert_eq!(
1554 oid_to_sha1(&ahead_2_oid), 1551 ahead,
1555 oid_to_sha1(&ahead_1_oid) 1552 vec![oid_to_sha1(&ahead_2_oid), oid_to_sha1(&ahead_1_oid)],
1556 ],); 1553 );
1557 assert_eq!(behind, vec![ 1554 assert_eq!(
1558 oid_to_sha1(&behind_2_oid), 1555 behind,
1559 oid_to_sha1(&behind_1_oid) 1556 vec![oid_to_sha1(&behind_2_oid), oid_to_sha1(&behind_1_oid)],
1560 ],); 1557 );
1561 Ok(()) 1558 Ok(())
1562 } 1559 }
1563 } 1560 }
@@ -2212,9 +2209,10 @@ mod tests {
2212 test_repo.populate_with_test_branch()?; 2209 test_repo.populate_with_test_branch()?;
2213 test_repo.checkout("main")?; 2210 test_repo.checkout("main")?;
2214 2211
2215 assert_eq!(git_repo.parse_starting_commits("HEAD~1")?, vec![ 2212 assert_eq!(
2216 str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")? 2213 git_repo.parse_starting_commits("HEAD~1")?,
2217 ],); 2214 vec![str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?],
2215 );
2218 Ok(()) 2216 Ok(())
2219 } 2217 }
2220 2218
@@ -2224,9 +2222,10 @@ mod tests {
2224 let git_repo = Repo::from_path(&test_repo.dir)?; 2222 let git_repo = Repo::from_path(&test_repo.dir)?;
2225 test_repo.populate_with_test_branch()?; 2223 test_repo.populate_with_test_branch()?;
2226 2224
2227 assert_eq!(git_repo.parse_starting_commits("HEAD~1")?, vec![ 2225 assert_eq!(
2228 str_to_sha1("82ff2bcc9aa94d1bd8faee723d4c8cc190d6061c")? 2226 git_repo.parse_starting_commits("HEAD~1")?,
2229 ],); 2227 vec![str_to_sha1("82ff2bcc9aa94d1bd8faee723d4c8cc190d6061c")?],
2228 );
2230 Ok(()) 2229 Ok(())
2231 } 2230 }
2232 } 2231 }
@@ -2240,10 +2239,13 @@ mod tests {
2240 test_repo.populate_with_test_branch()?; 2239 test_repo.populate_with_test_branch()?;
2241 test_repo.checkout("main")?; 2240 test_repo.checkout("main")?;
2242 2241
2243 assert_eq!(git_repo.parse_starting_commits("HEAD~2")?, vec![ 2242 assert_eq!(
2244 str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?, 2243 git_repo.parse_starting_commits("HEAD~2")?,
2245 str_to_sha1("af474d8d271490e5c635aad337abdc050034b16a")?, 2244 vec![
2246 ],); 2245 str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?,
2246 str_to_sha1("af474d8d271490e5c635aad337abdc050034b16a")?,
2247 ],
2248 );
2247 Ok(()) 2249 Ok(())
2248 } 2250 }
2249 } 2251 }
@@ -2256,11 +2258,14 @@ mod tests {
2256 let git_repo = Repo::from_path(&test_repo.dir)?; 2258 let git_repo = Repo::from_path(&test_repo.dir)?;
2257 test_repo.populate_with_test_branch()?; 2259 test_repo.populate_with_test_branch()?;
2258 2260
2259 assert_eq!(git_repo.parse_starting_commits("HEAD~3")?, vec![ 2261 assert_eq!(
2260 str_to_sha1("82ff2bcc9aa94d1bd8faee723d4c8cc190d6061c")?, 2262 git_repo.parse_starting_commits("HEAD~3")?,
2261 str_to_sha1("a23e6b05aaeb7d1471b4a838b51f337d5644eeb0")?, 2263 vec![
2262 str_to_sha1("7ab82116068982671a8111f27dc10599172334b2")?, 2264 str_to_sha1("82ff2bcc9aa94d1bd8faee723d4c8cc190d6061c")?,
2263 ],); 2265 str_to_sha1("a23e6b05aaeb7d1471b4a838b51f337d5644eeb0")?,
2266 str_to_sha1("7ab82116068982671a8111f27dc10599172334b2")?,
2267 ],
2268 );
2264 Ok(()) 2269 Ok(())
2265 } 2270 }
2266 } 2271 }
@@ -2274,11 +2279,14 @@ mod tests {
2274 test_repo.populate_with_test_branch()?; 2279 test_repo.populate_with_test_branch()?;
2275 test_repo.checkout("main")?; 2280 test_repo.checkout("main")?;
2276 2281
2277 assert_eq!(git_repo.parse_starting_commits("af474d8..a23e6b0")?, vec![ 2282 assert_eq!(
2278 str_to_sha1("a23e6b05aaeb7d1471b4a838b51f337d5644eeb0")?, 2283 git_repo.parse_starting_commits("af474d8..a23e6b0")?,
2279 str_to_sha1("7ab82116068982671a8111f27dc10599172334b2")?, 2284 vec![
2280 str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?, 2285 str_to_sha1("a23e6b05aaeb7d1471b4a838b51f337d5644eeb0")?,
2281 ],); 2286 str_to_sha1("7ab82116068982671a8111f27dc10599172334b2")?,
2287 str_to_sha1("431b84edc0d2fa118d63faa3c2db9c73d630a5ae")?,
2288 ],
2289 );
2282 Ok(()) 2290 Ok(())
2283 } 2291 }
2284 } 2292 }
diff --git a/src/lib/git/nostr_url.rs b/src/lib/git/nostr_url.rs
index a9b08eb..e9b482f 100644
--- a/src/lib/git/nostr_url.rs
+++ b/src/lib/git/nostr_url.rs
@@ -71,13 +71,13 @@ impl fmt::Display for NostrUrlDecoded {
71 } 71 }
72 write!(f, "nostr://")?; 72 write!(f, "nostr://")?;
73 if let Some(user) = &self.user { 73 if let Some(user) = &self.user {
74 write!(f, "{}@", user)?; 74 write!(f, "{user}@")?;
75 } 75 }
76 if let Some(protocol) = &self.protocol { 76 if let Some(protocol) = &self.protocol {
77 write!(f, "{}/", protocol)?; 77 write!(f, "{protocol}/")?;
78 } 78 }
79 if let Some(nip05) = &self.nip05 { 79 if let Some(nip05) = &self.nip05 {
80 write!(f, "{}/", nip05)?; 80 write!(f, "{nip05}/")?;
81 } else { 81 } else {
82 write!(f, "{}/", self.coordinate.public_key.to_bech32().unwrap())?; 82 write!(f, "{}/", self.coordinate.public_key.to_bech32().unwrap())?;
83 } 83 }
@@ -454,7 +454,7 @@ impl CloneUrl {
454 format!("{}@", user.as_deref().unwrap_or("git")).as_str(), 454 format!("{}@", user.as_deref().unwrap_or("git")).as_str(),
455 ); 455 );
456 if url.port().is_some() { 456 if url.port().is_some() {
457 formatted_url = format!("ssh://{}", formatted_url); 457 formatted_url = format!("ssh://{formatted_url}");
458 } else { 458 } else {
459 formatted_url = replace_first_occurrence(&formatted_url, '/', ':'); 459 formatted_url = replace_first_occurrence(&formatted_url, '/', ':');
460 } 460 }
diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs
index 3ce7637..69406c1 100644
--- a/src/lib/git_events.rs
+++ b/src/lib/git_events.rs
@@ -134,14 +134,15 @@ pub async fn generate_patch_event(
134 // code that makes it into the main branch, assuming 134 // code that makes it into the main branch, assuming
135 // the commit id is correct 135 // the commit id is correct
136 Tag::from_standardized(TagStandard::Reference(commit.to_string())), 136 Tag::from_standardized(TagStandard::Reference(commit.to_string())),
137 Tag::custom(TagKind::Custom(std::borrow::Cow::Borrowed("alt")), vec![ 137 Tag::custom(
138 format!( 138 TagKind::Custom(std::borrow::Cow::Borrowed("alt")),
139 vec![format!(
139 "git patch: {}", 140 "git patch: {}",
140 git_repo 141 git_repo
141 .get_commit_message_summary(commit) 142 .get_commit_message_summary(commit)
142 .unwrap_or_default() 143 .unwrap_or_default()
143 ), 144 )],
144 ]), 145 ),
145 ], 146 ],
146 if let Some(thread_event_id) = thread_event_id { 147 if let Some(thread_event_id) = thread_event_id {
147 vec![Tag::from_standardized(nostr_sdk::TagStandard::Event { 148 vec![Tag::from_standardized(nostr_sdk::TagStandard::Event {
@@ -205,9 +206,10 @@ pub async fn generate_patch_event(
205 .collect(), 206 .collect(),
206 vec![ 207 vec![
207 // a fallback is now in place to extract this from the patch 208 // a fallback is now in place to extract this from the patch
208 Tag::custom(TagKind::Custom(std::borrow::Cow::Borrowed("commit")), vec![ 209 Tag::custom(
209 commit.to_string(), 210 TagKind::Custom(std::borrow::Cow::Borrowed("commit")),
210 ]), 211 vec![commit.to_string()],
212 ),
211 // this is required as patches cannot be relied upon to include the 'base 213 // this is required as patches cannot be relied upon to include the 'base
212 // commit' 214 // commit'
213 Tag::custom( 215 Tag::custom(
diff --git a/src/lib/login/fresh.rs b/src/lib/login/fresh.rs
index 683d4af..a169177 100644
--- a/src/lib/login/fresh.rs
+++ b/src/lib/login/fresh.rs
@@ -278,7 +278,7 @@ pub async fn get_fresh_nip46_signer(
278 let input = Interactor::default() 278 let input = Interactor::default()
279 .input( 279 .input(
280 PromptInputParms::default().with_prompt(if let Some(error) = error { 280 PromptInputParms::default().with_prompt(if let Some(error) = error {
281 format!("error: {}. try again with NIP-05 address", error) 281 format!("error: {error}. try again with NIP-05 address")
282 } else { 282 } else {
283 "NIP-05 address".to_string() 283 "NIP-05 address".to_string()
284 }), 284 }),
@@ -296,7 +296,7 @@ pub async fn get_fresh_nip46_signer(
296 let input = Interactor::default() 296 let input = Interactor::default()
297 .input( 297 .input(
298 PromptInputParms::default().with_prompt(if let Some(error) = error { 298 PromptInputParms::default().with_prompt(if let Some(error) = error {
299 format!("error: {}. try again with bunker url", error) 299 format!("error: {error}. try again with bunker url")
300 } else { 300 } else {
301 "bunker url".to_string() 301 "bunker url".to_string()
302 }), 302 }),
@@ -505,7 +505,7 @@ async fn save_to_git_config(
505 if let Err(error) = 505 if let Err(error) =
506 silently_save_to_git_config(git_repo, signer_info, global).context(err_msg.clone()) 506 silently_save_to_git_config(git_repo, signer_info, global).context(err_msg.clone())
507 { 507 {
508 eprintln!("Error: {:?}", error); 508 eprintln!("Error: {error:?}");
509 match signer_info { 509 match signer_info {
510 SignerInfo::Nsec { 510 SignerInfo::Nsec {
511 nsec, 511 nsec,
@@ -577,7 +577,7 @@ async fn save_to_git_config(
577 ), 577 ),
578 ) 578 )
579 { 579 {
580 eprintln!("Error: {:?}", error); 580 eprintln!("Error: {error:?}");
581 eprintln!("login details were not saved"); 581 eprintln!("login details were not saved");
582 } else { 582 } else {
583 eprintln!( 583 eprintln!(
diff --git a/src/lib/login/mod.rs b/src/lib/login/mod.rs
index bfc7328..3fcd755 100644
--- a/src/lib/login/mod.rs
+++ b/src/lib/login/mod.rs
@@ -79,11 +79,15 @@ fn print_logged_in_as(
79 "failed to find your relay list. consider using another nostr client to create one to enhance your nostr experience." 79 "failed to find your relay list. consider using another nostr client to create one to enhance your nostr experience."
80 ); 80 );
81 } 81 }
82 eprintln!("logged in as {}{}", user_ref.metadata.name, match source { 82 eprintln!(
83 SignerInfoSource::CommandLineArguments => " via cli arguments", 83 "logged in as {}{}",
84 SignerInfoSource::GitLocal => " to local repository", 84 user_ref.metadata.name,
85 SignerInfoSource::GitGlobal => "", 85 match source {
86 }); 86 SignerInfoSource::CommandLineArguments => " via cli arguments",
87 SignerInfoSource::GitLocal => " to local repository",
88 SignerInfoSource::GitGlobal => "",
89 }
90 );
87 Ok(()) 91 Ok(())
88} 92}
89 93
diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs
index c1fc288..0236e34 100644
--- a/src/lib/repo_ref.rs
+++ b/src/lib/repo_ref.rs
@@ -578,11 +578,14 @@ pub fn save_repo_config_to_yaml(
578 .context("failed to convert public key into npub")?, 578 .context("failed to convert public key into npub")?,
579 ); 579 );
580 } 580 }
581 serde_yaml::to_writer(file, &RepoConfigYaml { 581 serde_yaml::to_writer(
582 identifier: Some(identifier), 582 file,
583 maintainers: maintainers_npubs, 583 &RepoConfigYaml {
584 relays, 584 identifier: Some(identifier),
585 }) 585 maintainers: maintainers_npubs,
586 relays,
587 },
588 )
586 .context("failed to write maintainers to maintainers.yaml file serde_yaml") 589 .context("failed to write maintainers to maintainers.yaml file serde_yaml")
587} 590}
588 591
diff --git a/src/lib/repo_state.rs b/src/lib/repo_state.rs
index 04f3cf2..345f05c 100644
--- a/src/lib/repo_state.rs
+++ b/src/lib/repo_state.rs
@@ -56,9 +56,10 @@ impl RepoState {
56 add_head(&mut state); 56 add_head(&mut state);
57 let mut tags = vec![Tag::identifier(identifier.clone())]; 57 let mut tags = vec![Tag::identifier(identifier.clone())];
58 for (name, value) in &state { 58 for (name, value) in &state {
59 tags.push(Tag::custom(nostr_sdk::TagKind::Custom(name.into()), vec![ 59 tags.push(Tag::custom(
60 value.clone(), 60 nostr_sdk::TagKind::Custom(name.into()),
61 ])); 61 vec![value.clone()],
62 ));
62 } 63 }
63 let event = sign_event( 64 let event = sign_event(
64 EventBuilder::new(STATE_KIND, "").tags(tags), 65 EventBuilder::new(STATE_KIND, "").tags(tags),