Skip to content

Commit 7655f5d

Browse files
committed
rename consts to match SigningKey.Format
1 parent 6d119a0 commit 7655f5d

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

modules/git/key.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ package git
55

66
// Based on https://git-scm.com/docs/git-config#Documentation/git-config.txt-gpgformat
77
const (
8-
// KeyTypeOpenPGP is the key type for GPG keys, expected default of git cli
9-
KeyTypeOpenPGP = "openpgp"
10-
// KeyTypeSSH is the key type for SSH keys
11-
KeyTypeSSH = "ssh"
8+
SigningKeyFormatOpenPGP = "openpgp" // for GPG keys, the expected default of git cli
9+
SigningKeyFormatSSH = "ssh"
1210
)
1311

1412
type SigningKey struct {

modules/git/repo_gpg.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// LoadPublicKeyContent will load the key from gpg
1616
func (gpgSettings *GPGSettings) LoadPublicKeyContent() error {
17-
if gpgSettings.Format == KeyTypeSSH {
17+
if gpgSettings.Format == SigningKeyFormatSSH {
1818
content, err := os.ReadFile(gpgSettings.KeyID)
1919
if err != nil {
2020
return fmt.Errorf("unable to read SSH public key file: %s, %w", gpgSettings.KeyID, err)
@@ -53,7 +53,7 @@ func (repo *Repository) GetDefaultPublicGPGKey(forceUpdate bool) (*GPGSettings,
5353
signingKey, _, _ := NewCommand("config", "--get", "user.signingkey").RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
5454
gpgSettings.KeyID = strings.TrimSpace(signingKey)
5555

56-
format, _, _ := NewCommand("config", "--default", KeyTypeOpenPGP, "--get", "gpg.format").RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
56+
format, _, _ := NewCommand("config", "--default", SigningKeyFormatOpenPGP, "--get", "gpg.format").RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
5757
gpgSettings.Format = strings.TrimSpace(format)
5858

5959
defaultEmail, _, _ := NewCommand("config", "--get", "user.email").RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})

routers/api/v1/misc/signing.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func SigningKeyGPG(ctx *context.APIContext) {
6565
// description: "GPG armored public key"
6666
// schema:
6767
// type: string
68-
getSigningKey(ctx, git.KeyTypeOpenPGP)
68+
getSigningKey(ctx, git.SigningKeyFormatOpenPGP)
6969
}
7070

7171
// SigningKeySSH returns the public key of the default signing key if it exists
@@ -102,5 +102,5 @@ func SigningKeySSH(ctx *context.APIContext) {
102102
// description: "ssh public key"
103103
// schema:
104104
// type: string
105-
getSigningKey(ctx, git.KeyTypeSSH)
105+
getSigningKey(ctx, git.SigningKeyFormatSSH)
106106
}

services/asymkey/commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func ParseCommitWithSSHSignature(ctx context.Context, c *git.Commit, committerUs
428428
}
429429

430430
// Try the configured instance-wide SSH public key
431-
if setting.Repository.Signing.SigningFormat == git.KeyTypeSSH && !slices.Contains([]string{"", "default", "none"}, setting.Repository.Signing.SigningKey) {
431+
if setting.Repository.Signing.SigningFormat == git.SigningKeyFormatSSH && !slices.Contains([]string{"", "default", "none"}, setting.Repository.Signing.SigningKey) {
432432
gpgSettings := git.GPGSettings{
433433
Sign: true,
434434
KeyID: setting.Repository.Signing.SigningKey,

services/asymkey/sign.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func SigningKey(ctx context.Context, repoPath string) (*git.SigningKey, *git.Sig
9999
return nil, nil
100100
}
101101

102-
format, _, _ := git.NewCommand("config", "--default", git.KeyTypeOpenPGP, "--get", "gpg.format").RunStdString(ctx, &git.RunOpts{Dir: repoPath})
102+
format, _, _ := git.NewCommand("config", "--default", git.SigningKeyFormatOpenPGP, "--get", "gpg.format").RunStdString(ctx, &git.RunOpts{Dir: repoPath})
103103
signingKey, _, _ := git.NewCommand("config", "--get", "user.signingkey").RunStdString(ctx, &git.RunOpts{Dir: repoPath})
104104
signingName, _, _ := git.NewCommand("config", "--get", "user.name").RunStdString(ctx, &git.RunOpts{Dir: repoPath})
105105
signingEmail, _, _ := git.NewCommand("config", "--get", "user.email").RunStdString(ctx, &git.RunOpts{Dir: repoPath})
@@ -136,7 +136,7 @@ func PublicSigningKey(ctx context.Context, repoPath string) (content string, for
136136
if signingKey == nil {
137137
return "", "", nil
138138
}
139-
if signingKey.Format == git.KeyTypeSSH {
139+
if signingKey.Format == git.SigningKeyFormatSSH {
140140
content, err := os.ReadFile(signingKey.KeyID)
141141
if err != nil {
142142
log.Error("Unable to read SSH public key file in %s: %s, %v", repoPath, signingKey, err)

0 commit comments

Comments
 (0)