Skip to content

Commit c841801

Browse files
committed
Fail if commit is already signed
1 parent af20207 commit c841801

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gitoxide-core/src/repository/commit.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,14 @@ pub fn sign(repo: gix::Repository, rev_spec: Option<&str>, mut out: impl std::io
9090

9191
let extra_header: Cow<'_, BStr> = Cow::Borrowed(signed_data.as_bstr());
9292

93-
// TODO:
94-
// What do we want to do when there is already a signature?
93+
assert!(
94+
!commit_ref
95+
.extra_headers
96+
.iter()
97+
.any(|(header_name, _)| *header_name == BStr::new(SIGNATURE_FIELD_NAME)),
98+
"Commit is already signed, doing nothing"
99+
);
100+
95101
commit_ref
96102
.extra_headers
97103
.push((BStr::new(SIGNATURE_FIELD_NAME), extra_header));

0 commit comments

Comments
 (0)