Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Sign commit using GPG when possible #2

Open
anton-yurchenko opened this issue Jul 28, 2021 · 4 comments
Open

[Feature]: Sign commit using GPG when possible #2

anton-yurchenko opened this issue Jul 28, 2021 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@anton-yurchenko
Copy link
Owner

anton-yurchenko commented Jul 28, 2021

In case the user has configured to use a GPG key to sign a commit, version-bump should use that key to sign the commit it creates as well.

image

@anton-yurchenko anton-yurchenko self-assigned this Jul 28, 2021
@anton-yurchenko anton-yurchenko added the enhancement New feature or request label Jul 28, 2021
@anton-yurchenko
Copy link
Owner Author

git config --list has two important settings that must be taken into account:

user.signingkey=XXXXXXXXXXXXXXXX
commit.gpgsign=true

@anton-yurchenko anton-yurchenko added the help wanted Extra attention is needed label Mar 13, 2022
@anton-yurchenko
Copy link
Owner Author

It seems that the go-git is unable to load the local git client settings.

@anton-yurchenko anton-yurchenko removed their assignment Oct 15, 2023
@joe-at-startupmedia
Copy link

Any updates on this?
https://github.com/go-git/go-git/blob/95afe7e1cdf71c59ee8a71971fac71880020a744/worktree_commit_test.go#L475

Looks like it grabs the contents of the gpg key so I'm not sure how you'd go about providing that configurability in this repo.

Methods to retrieve from local config:
https://github.com/go-git/go-git/blob/95afe7e1cdf71c59ee8a71971fac71880020a744/repository.go#L566

@joe-at-startupmedia
Copy link

joe-at-startupmedia commented Oct 16, 2024

I tested this and it still doesn't work using repo.ConfigScoped with config.GlobalScope.

The following however does work:

	gitConfig, err := config.LoadConfig(config.GlobalScope)
	log.Info(gitConfig.Raw.Sections.GoString())

	userSection := gitConfig.Raw.Section("user")
	log.Info(userSection)
	log.Info(userSection.Options.Get("signingkey"))

	commitSection := gitConfig.Raw.Section("commit")
	log.Info(commitSection)
	log.Info(commitSection.Options.Get("gpgsign"))

So it seems like the best way to handle this is falling back to config.LoadConfig with the config.GlobalScope when the same key-values grabbed from the Raw sections are non-existent from repo.ConfigScoped with config.GlobalScope.

There is a relevant issue open about this but it seems to be stale:
go-git/go-git#395

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants