Skip to content

Commit 53f36a1

Browse files
author
Naseschwarz
committed
Favor Repository::workdir() over path().parent()
This more clearly errors in case of bare repositories instead of using the parent directory of the bare repository, for the hooks tested here, none of which support the hooks tested.
1 parent 0d06a50 commit 53f36a1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

asyncgit/src/sync/hooks.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ mod tests {
9797
#[test]
9898
fn test_post_commit_hook_reject_in_subfolder() {
9999
let (_td, repo) = repo_init().unwrap();
100-
let root = repo.path().parent().unwrap();
100+
let root = repo.workdir().unwrap();
101101

102102
let hook = b"#!/bin/sh
103103
echo 'rejected'
@@ -130,7 +130,7 @@ mod tests {
130130
#[cfg(unix)]
131131
fn test_pre_commit_workdir() {
132132
let (_td, repo) = repo_init().unwrap();
133-
let root = repo.path().parent().unwrap();
133+
let root = repo.workdir().unwrap();
134134
let repo_path: &RepoPath =
135135
&root.as_os_str().to_str().unwrap().into();
136136
let workdir =
@@ -160,7 +160,7 @@ mod tests {
160160
#[test]
161161
fn test_hooks_commit_msg_reject_in_subfolder() {
162162
let (_td, repo) = repo_init().unwrap();
163-
let root = repo.path().parent().unwrap();
163+
let root = repo.workdir().unwrap();
164164

165165
let hook = b"#!/bin/sh
166166
echo 'msg' > $1
@@ -196,7 +196,7 @@ mod tests {
196196
fn test_hooks_commit_msg_reject_in_hooks_folder_githooks_moved_absolute(
197197
) {
198198
let (_td, repo) = repo_init().unwrap();
199-
let root = repo.path().parent().unwrap();
199+
let root = repo.workdir().unwrap();
200200
let mut config = repo.config().unwrap();
201201

202202
const HOOKS_DIR: &'static str = "my_hooks";

0 commit comments

Comments
 (0)