File tree 2 files changed +14
-6
lines changed
2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 39
39
if : matrix.os == 'macos-latest'
40
40
run : brew install gpgme
41
41
42
+ - name : Install GnuPG on Windows
43
+ if : matrix.os == 'windows-latest'
44
+ run : choco install gnupg
45
+
42
46
- name : Build Debug
43
47
run : |
44
48
rustc --version
Original file line number Diff line number Diff line change @@ -70,7 +70,10 @@ pub fn commit(repo_path: &str, msg: &str) -> Result<CommitId> {
70
70
71
71
let parents = parents. iter ( ) . collect :: < Vec < _ > > ( ) ;
72
72
73
- let commit_oid = if config. get_bool ( "commit.gpgsign" ) ? {
73
+ let commit_oid = if config
74
+ . get_bool ( "commit.gpgsign" )
75
+ . unwrap_or ( false )
76
+ {
74
77
// Generate commit content
75
78
let commit_bufffer = repo. commit_create_buffer (
76
79
& signature,
@@ -85,17 +88,18 @@ pub fn commit(repo_path: &str, msg: &str) -> Result<CommitId> {
85
88
86
89
// Prepare to sign using the designated key in the user's git config
87
90
let mut gpg_ctx = Context :: from_protocol ( Protocol :: OpenPgp ) ?;
88
- let key =
89
- gpg_ctx. get_key ( config. get_string ( "user.signingkey" ) ?) ?;
90
- gpg_ctx. add_signer ( & key) ?;
91
+ if let Ok ( key_id) = config. get_string ( "user.signingkey" ) {
92
+ let key = gpg_ctx. get_key ( key_id) ?;
93
+ gpg_ctx. add_signer ( & key) ?;
94
+ }
91
95
gpg_ctx. set_armor ( true ) ;
92
96
93
97
// Create GPG signature for commit content
94
98
let mut signature_buffer = Vec :: new ( ) ;
95
99
gpg_ctx
96
100
. sign_detached ( & * commit_bufffer, & mut signature_buffer) ?;
97
- let gpg_signature =
98
- std :: str :: from_utf8 ( & signature_buffer ) . unwrap ( ) ;
101
+ let gpg_signature = std :: str :: from_utf8 ( & signature_buffer )
102
+ . expect ( "Buffer was not valid UTF-8" ) ;
99
103
100
104
let commit_oid = repo. commit_signed (
101
105
& commit_content,
You can’t perform that action at this time.
0 commit comments