Skip to content

Commit 6d2e53c

Browse files
committed
tests for author/committer/user (#331)
1 parent 4dc6594 commit 6d2e53c

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:506336963df7857dadb52b694cdaa19679b63419f114bc91ae0ef25728a5c01a
3-
size 9320
2+
oid sha256:035cf83cc4e212ac2df20c905dd09f27142832fc5ad5c7950d9b85ea51a672cd
3+
size 9360

Diff for: git-repository/tests/fixtures/make_config_repo.sh

+8
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@ cat <<EOF >>.git/config
1919
2020
[include]
2121
path = ../a.config
22+
23+
[user]
24+
name = user
25+
email = user@email
2226
EOF
2327

2428

2529
cat <<EOF >>a.config
2630
[a]
2731
local-override = from-a.config
32+
33+
[committer]
34+
name = committer
35+
email = committer@email
2836
EOF
2937
cat <<EOF >>b.config
3038
[a]

Diff for: git-repository/tests/repository/config.rs

+33
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ fn access_values() {
1616
"GIT_CONFIG_SYSTEM",
1717
work_dir.join("system.config").display().to_string(),
1818
)
19+
.set("GIT_AUTHOR_NAME", "author")
20+
.set("GIT_AUTHOR_EMAIL", "author@email")
21+
.set("GIT_AUTHOR_DATE", "1979-02-26 18:30:00")
1922
.set("GIT_CONFIG_COUNT", "1")
2023
.set("GIT_CONFIG_KEY_0", "include.path")
2124
.set("GIT_CONFIG_VALUE_0", work_dir.join("c.config").display().to_string());
@@ -32,6 +35,36 @@ fn access_values() {
3235
)
3336
.unwrap();
3437

38+
assert_eq!(
39+
repo.author(),
40+
Some(git_actor::SignatureRef {
41+
name: "author".into(),
42+
email: "author@email".into(),
43+
time: git_date::Time {
44+
seconds_since_unix_epoch: 42,
45+
offset_in_seconds: 1800,
46+
sign: git_date::time::Sign::Plus
47+
}
48+
}),
49+
"the only parsesable marker time we know right now, indicating time parse success"
50+
);
51+
assert_eq!(
52+
repo.committer(),
53+
Some(git_actor::SignatureRef {
54+
name: "committer".into(),
55+
email: "committer@email".into(),
56+
time: git_date::Time::now_local_or_utc()
57+
})
58+
);
59+
assert_eq!(
60+
repo.user_default(),
61+
git_actor::SignatureRef {
62+
name: "gitoxide".into(),
63+
email: "gitoxide@localhost".into(),
64+
time: git_date::Time::now_local_or_utc()
65+
}
66+
);
67+
3568
let config = repo.config_snapshot();
3669

3770
assert_eq!(config.boolean("core.bare"), Some(false));

0 commit comments

Comments
 (0)