Remembering file modes and entering them into a text editor is error
prone when a compiler does not check you have done it
correctly. Unfortunately, there was a missing `0` for the file mode
for writing a tree entry.
Use the `FileMode` enum instead and its instance for `Into<i32>`.
The tracked_reference test that is using `quick_commit` was altered to
test that a tree with sub directories can be written.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
---
Published-as: https://github.com/FintanH/radicle-link/tree/patches/fix%2Ftree-write%2Fv1
git-ext/src/tree.rs | 4 ++--
.../t/src/integration/scenario/tracked_references.rs | 12 +++++++++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/git-ext/src/tree.rs b/git-ext/src/tree.rs
index 589a781d..86106b5b 100644
--- a/git-ext/src/tree.rs+++ b/git-ext/src/tree.rs
@@ -69,11 +69,11 @@ impl Tree<'_> {
match node {
Blob(data) => {
let oid = repo.blob(data)?;
- builder.insert(name.as_ref(), oid, 0o100644)?;+ builder.insert(name.as_ref(), oid, git2::FileMode::Blob.into())?; },
Tree(sub) => {
let oid = sub.write(repo)?;
- builder.insert(name.as_ref(), oid, 0o04000)?;+ builder.insert(name.as_ref(), oid, git2::FileMode::Tree.into())?; },
}
}
diff --git a/librad/t/src/integration/scenario/tracked_references.rs b/librad/t/src/integration/scenario/tracked_references.rs
index e2d9b729..c58265dd 100644
--- a/librad/t/src/integration/scenario/tracked_references.rs+++ b/librad/t/src/integration/scenario/tracked_references.rs
@@ -111,7 +111,17 @@ fn can_see_tracked_references() {
quick_commit(
storage,
&urn.with_path(reflike!("refs/heads/master")),
- vec![("HI", tree::blob(b"Hi Bob"))].into_iter().collect(),+ vec![+ ("HI", tree::blob(b"Hi Bob")),+ (+ "src",+ vec![("main.rs", tree::blob(b"fn main() {}"))]+ .into_iter()+ .collect(),+ ),+ ]+ .into_iter()+ .collect(), "say hi to bob",
)
}
--
2.31.1