Skip to content

Commit af20207

Browse files
committed
Print signed commit's id to stdout
1 parent aaeea74 commit af20207

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

gitoxide-core/src/repository/commit.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn verify(repo: gix::Repository, rev_spec: Option<&str>) -> Result<()> {
4747
Ok(())
4848
}
4949

50-
pub fn sign(repo: gix::Repository, rev_spec: Option<&str>) -> Result<()> {
50+
pub fn sign(repo: gix::Repository, rev_spec: Option<&str>, mut out: impl std::io::Write) -> Result<()> {
5151
let rev_spec = rev_spec.unwrap_or("HEAD");
5252
let commit = repo
5353
.rev_parse_single(format!("{rev_spec}^{{commit}}").as_str())?
@@ -96,7 +96,9 @@ pub fn sign(repo: gix::Repository, rev_spec: Option<&str>) -> Result<()> {
9696
.extra_headers
9797
.push((BStr::new(SIGNATURE_FIELD_NAME), extra_header));
9898

99-
eprintln!("{commit_ref:?}");
99+
let signed_id = repo.write_object(&commit_ref)?;
100+
101+
writeln!(&mut out, "{signed_id}")?;
100102

101103
Ok(())
102104
}

src/plumbing/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,8 @@ pub fn main() -> Result<()> {
12941294
progress,
12951295
progress_keep_open,
12961296
None,
1297-
move |_progress, _out, _err| {
1298-
core::repository::commit::sign(repository(Mode::Lenient)?, rev_spec.as_deref())
1297+
move |_progress, out, _err| {
1298+
core::repository::commit::sign(repository(Mode::Lenient)?, rev_spec.as_deref(), out)
12991299
},
13001300
),
13011301
commit::Subcommands::Describe {

0 commit comments

Comments
 (0)