From 8d451e3d9d6c0121b0ed3e4ac6cbf710625e9f9d Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Fri, 16 Dec 2022 10:54:55 +0000 Subject: [PATCH 1/2] nix: update to rust-1.66 Rust 1.66.0 was announced[0]. The code fixes were all for the clippy warning regarding needless borrows. The doc tool now parses for HTML, so any now needs to be wrapped in backticks, i.e. ``. [0]: https://blog.rust-lang.org/2022/12/15/Rust-1.66.0.html Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- git-ref-format/core/src/deriv.rs | 2 +- git-ref-format/core/src/refspec.rs | 2 +- link-git/src/service.rs | 2 +- nix/sources.json | 6 +++--- radicle-git-types/src/reference.rs | 6 +++--- radicle-surf/examples/browsing.rs | 2 +- radicle-surf/t/src/file_system.rs | 4 ++-- radicle-surf/t/src/git/code_browsing.rs | 4 ++-- radicle-surf/t/src/git/diff.rs | 4 ++-- radicle-surf/t/src/git/last_commit.rs | 2 +- radicle-surf/t/src/git/submodule.rs | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/git-ref-format/core/src/deriv.rs b/git-ref-format/core/src/deriv.rs index 8b11a86..2b8d597 100644 --- a/git-ref-format/core/src/deriv.rs +++ b/git-ref-format/core/src/deriv.rs @@ -96,7 +96,7 @@ impl<'a> Qualified<'a> { /// Add a namespace. /// /// Creates a new [`Namespaced`] by prefxing `self` with - /// "refs/namespaces/". + /// `refs/namespaces/`. pub fn with_namespace<'b>(&self, ns: Component<'b>) -> Namespaced<'a> { Namespaced(Cow::Owned( IntoIterator::into_iter([lit::Refs.into(), lit::Namespaces.into(), ns]) diff --git a/git-ref-format/core/src/refspec.rs b/git-ref-format/core/src/refspec.rs index 5bd19dd..2b1d018 100644 --- a/git-ref-format/core/src/refspec.rs +++ b/git-ref-format/core/src/refspec.rs @@ -345,7 +345,7 @@ impl<'a> QualifiedPattern<'a> { /// Add a namespace. /// /// Creates a new [`NamespacedPattern`] by prefxing `self` with - /// "refs/namespaces/". + /// `refs/namespaces/`. pub fn with_namespace<'b>( &self, ns: Component<'b>, diff --git a/link-git/src/service.rs b/link-git/src/service.rs index f508dce..98b0158 100644 --- a/link-git/src/service.rs +++ b/link-git/src/service.rs @@ -19,7 +19,7 @@ pub struct Service(pub GitService); /// talking to an SSH remote. The `FromStr` implementation for this type expects /// a string of the form: /// -/// / +/// ` /` /// /// Where the request type is either `upload-pack` or `receive-pack`, the /// leading slash before the urn is optional, and the `path` is whatever the diff --git a/nix/sources.json b/nix/sources.json index 84cee68..53ebb72 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -29,10 +29,10 @@ "homepage": "", "owner": "oxalica", "repo": "rust-overlay", - "rev": "cf668f737ac986c0a89e83b6b2e3c5ddbd8cf33b", - "sha256": "0xaswxxjkx5fjjl1c7gp27qajvpl9qsi0rmj044hhmjrrlpb6nvd", + "rev": "7da2f6b3a0c32f661cb2864d7fbd1d7e6f0c7543", + "sha256": "1daw246p4aimvx9h3cf034dsyimh9d2ww19v4fx45mcmlqw1mx42", "type": "tarball", - "url": "https://github.com/oxalica/rust-overlay/archive/cf668f737ac986c0a89e83b6b2e3c5ddbd8cf33b.tar.gz", + "url": "https://github.com/oxalica/rust-overlay/archive/7da2f6b3a0c32f661cb2864d7fbd1d7e6f0c7543.tar.gz", "url_template": "https://github.com///archive/.tar.gz" } } diff --git a/radicle-git-types/src/reference.rs b/radicle-git-types/src/reference.rs index ea4f960..1b4dcb7 100644 --- a/radicle-git-types/src/reference.rs +++ b/radicle-git-types/src/reference.rs @@ -283,7 +283,7 @@ impl Reference { /// Build a reference that points to: /// * `refs/namespaces//refs/heads/` - /// * `refs/namespaces//refs/remote//heads/ + /// * `refs/namespaces//refs/remote//heads/` pub fn head(namespace: impl Into>, remote: impl Into>, name: One) -> Self { Self { remote: remote.into(), @@ -295,7 +295,7 @@ impl Reference { /// Build a reference that points to: /// * `refs/namespaces//refs/tags/` - /// * `refs/namespaces//refs/remote//tags/ + /// * `refs/namespaces//refs/remote//tags/` pub fn tag(namespace: impl Into>, remote: impl Into>, name: One) -> Self { Self { remote: remote.into(), @@ -390,7 +390,7 @@ impl Reference { where Self: ToString, { - ext::References::from_globs(repo, &[self.to_string()]) + ext::References::from_globs(repo, [self.to_string()]) } /// Build a reference that points to: diff --git a/radicle-surf/examples/browsing.rs b/radicle-surf/examples/browsing.rs index df04cce..f1b1052 100644 --- a/radicle-surf/examples/browsing.rs +++ b/radicle-surf/examples/browsing.rs @@ -38,7 +38,7 @@ fn main() { return; }, }; - let repo = Repository::discover(&repo_path).unwrap(); + let repo = Repository::discover(repo_path).unwrap(); let now = Instant::now(); let head = repo.head().unwrap(); let root = repo.root_dir(head).unwrap(); diff --git a/radicle-surf/t/src/file_system.rs b/radicle-surf/t/src/file_system.rs index 0ee2a2b..e232dd1 100644 --- a/radicle-surf/t/src/file_system.rs +++ b/radicle-surf/t/src/file_system.rs @@ -16,7 +16,7 @@ mod directory { #[test] fn directory_find_entry() { let repo = Repository::open(GIT_PLATINUM).unwrap(); - let root = repo.root_dir(&Branch::local(refname!("master"))).unwrap(); + let root = repo.root_dir(Branch::local(refname!("master"))).unwrap(); // find_entry for a file. let path = Path::new("src/memory.rs"); @@ -95,7 +95,7 @@ mod directory { #[test] fn directory_size() { let repo = Repository::open(GIT_PLATINUM).unwrap(); - let root = repo.root_dir(&Branch::local(refname!("master"))).unwrap(); + let root = repo.root_dir(Branch::local(refname!("master"))).unwrap(); /* git-platinum (master) $ ls -l src diff --git a/radicle-surf/t/src/git/code_browsing.rs b/radicle-surf/t/src/git/code_browsing.rs index fb846dd..2aa0795 100644 --- a/radicle-surf/t/src/git/code_browsing.rs +++ b/radicle-surf/t/src/git/code_browsing.rs @@ -12,7 +12,7 @@ use super::GIT_PLATINUM; fn iterate_root_dir_recursive() { let repo = Repository::open(GIT_PLATINUM).unwrap(); - let root_dir = repo.root_dir(&Branch::local(refname!("master"))).unwrap(); + let root_dir = repo.root_dir(Branch::local(refname!("master"))).unwrap(); let count = println_dir(&root_dir, &repo); assert_eq!(count, 36); // Check total file count. @@ -42,7 +42,7 @@ fn iterate_root_dir_recursive() { fn browse_repo_lazily() { let repo = Repository::open(GIT_PLATINUM).unwrap(); - let root_dir = repo.root_dir(&Branch::local(refname!("master"))).unwrap(); + let root_dir = repo.root_dir(Branch::local(refname!("master"))).unwrap(); let count = root_dir.entries(&repo).unwrap().entries().count(); assert_eq!(count, 8); let count = traverse(&root_dir, &repo); diff --git a/radicle-surf/t/src/git/diff.rs b/radicle-surf/t/src/git/diff.rs index 0c22fdb..9098f06 100644 --- a/radicle-surf/t/src/git/diff.rs +++ b/radicle-surf/t/src/git/diff.rs @@ -116,8 +116,8 @@ fn test_diff() -> Result<(), Error> { fn test_branch_diff() -> Result<(), Error> { let repo = Repository::open(GIT_PLATINUM)?; let diff = repo.diff( - &Branch::local(refname!("master")), - &Branch::local(refname!("dev")), + Branch::local(refname!("master")), + Branch::local(refname!("dev")), )?; println!("Diff two branches: master -> dev"); diff --git a/radicle-surf/t/src/git/last_commit.rs b/radicle-surf/t/src/git/last_commit.rs index d12dd18..c461724 100644 --- a/radicle-surf/t/src/git/last_commit.rs +++ b/radicle-surf/t/src/git/last_commit.rs @@ -103,7 +103,7 @@ fn root() { .expect("Could not retrieve ./data/git-platinum as git repository"); let rev = Branch::local(refname!("master")); let root_last_commit_id = repo - .last_commit(&PathBuf::new(), &rev) + .last_commit(PathBuf::new(), rev) .expect("Failed to get last commit") .map(|commit| commit.id); diff --git a/radicle-surf/t/src/git/submodule.rs b/radicle-surf/t/src/git/submodule.rs index 1410e88..d2a931b 100644 --- a/radicle-surf/t/src/git/submodule.rs +++ b/radicle-surf/t/src/git/submodule.rs @@ -6,5 +6,5 @@ fn test_submodule_failure() { use radicle_surf::git::{Branch, Repository}; let repo = Repository::discover(".").unwrap(); - repo.root_dir(&Branch::local(refname!("main"))).unwrap(); + repo.root_dir(Branch::local(refname!("main"))).unwrap(); } From 01e2305a41395d98ba869d8c8445d176edc289a9 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Fri, 16 Dec 2022 11:00:16 +0000 Subject: [PATCH 2/2] surf: missed expect from refactoring diff A placeholder `.expect("TODO")` was left in the diff code while refactoring. Change the `expect` to `?` and use the correct `type Error`. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-surf/src/diff/git.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radicle-surf/src/diff/git.rs b/radicle-surf/src/diff/git.rs index 180498e..eabe58f 100644 --- a/radicle-surf/src/diff/git.rs +++ b/radicle-surf/src/diff/git.rs @@ -129,7 +129,7 @@ impl TryFrom> for Hunks { } impl TryFrom> for Hunks { - type Error = git2::Error; + type Error = error::Deletion; fn try_from(patch: git2::Patch) -> Result { let mut hunks = Vec::with_capacity(patch.num_hunks()); @@ -140,7 +140,7 @@ impl TryFrom> for Hunks { for l in 0..hunk_lines { let line = patch.line_in_hunk(h, l)?; - lines.push(Deletion::try_from(line).expect("TODO")); + lines.push(Deletion::try_from(line)?); } hunks.push(Hunk { header, lines }) }