-
-
Notifications
You must be signed in to change notification settings - Fork 507
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
.gitconfig parser #2395
.gitconfig parser #2395
Conversation
7fe184b
to
e5b1560
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I haven't yet started to dig into the big changes yet. A few comments. I'll keep going later.
0667dd2
to
20c15ba
Compare
2781b20
to
dfb8fcb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
70/114 reviewed, but I'm getting to the big chunks. Here's a few initial comments and I'll go through the rest tomorrow hopefully.
cb9d479
to
0c5a9ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, 105/114 I just haven't looked at the gitconfig package itself right now.
4722169
to
c144d02
Compare
localConfig = "config" | ||
// WorktreeConfig is the name of the local worktree configuration. Can be used to override | ||
// a committed local config. | ||
worktreeConfig = "config.worktree" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that worktree configs are even worse, since their config is stored in the original repo's .git
folder under .git/worktrees/nameofwt/config.worktree
e.g. if I have a worktree named "myown" located at /home/anomalroil/code/myown
for gopass it would look like:
file:/home/anomalroil/.gitconfig commit.gpgsign=true
file:/home/anomalroil/code/gopass/.git/config user.email=anomalroil@users.noreply.github.com
file:/home/anomalroil/code/gopass/.git/worktrees/myown/config.worktree user.name=TEST
because in a worktree, the folder .git
is replaced with a file .git
specifying the location of its original gitdir:
$ cat .git
gitdir: /home/anomalroil/code/drand/.git/worktrees/myown
Is this currently taken into account?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it isn't. And I wasn't aware of that. Thank you. I don't necessarily plan to support this as part of this PR, but it's definitely something that needs to be documented and should have a TODO. Will add that and then resolve this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading https://git-scm.com/docs/git-config#SCOPES I'm not sure if that's correct - but I haven't used this feature before so I might be wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last one for today, I hope to wrap it up tomorrow!
@AnomalRoil Thanks a lot. I'll probably not get to address the open comments until tomorrow anyway. If you could leave any remaining comments today that'd be fantastic. Maybe we can wrap this up until the end of the week 😃 |
0fae794
to
6b2a2af
Compare
| `mounts.path` | `string` | Path to the root store. | `$XDG_DATA_HOME/gopass/stores/root` | | ||
| `core.showsafecontent` | `bool` | Only output *safe content* (i.e. everything but the first line of a secret) to the terminal. Use *copy* (`-c`) to retrieve the password in the clipboard, or *force* (`-f`) to still print it. | `false` | | ||
| `age.usekeychain` | `bool` | Use the OS keychain to cache age passphrases. | `false` | | ||
| `domain-alias.<from>` | `string` | Alias from domain to the string value of this entry. | `` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `domain-alias.<from>` | `string` | Alias from domain to the string value of this entry. | `` | | |
| `domain-alias.<from>` | `string` | Alias from domain to the string value of this entry. | `""` | |
Empty code doesn't work in github markdown, so I guess we can stick to the classical way of representing the empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still holds I guess ^
`` isn't valid markdown on GH.
@@ -32,6 +33,8 @@ func init() { | |||
return | |||
} | |||
|
|||
debug.Log("GOPASS_AUTOSYNC_INTERVAL is deprecated. Please use autosync.interval") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is a silent debug.Log
instead of a noisy out.Warning
because of the lack of context in init
?
@@ -181,11 +204,12 @@ func (s *Action) syncMount(ctx context.Context, mp string) error { | |||
} | |||
syncPrintDiff(ctxno, l, ln) | |||
|
|||
debug.Log("Syncing Mount %s. Exportkeys: %t", mp, ctxutil.IsExportKeys(ctx)) | |||
exportKeys := s.cfg.GetBool("core.exportkeys") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this also be a s.cfg.GetM
since it could be mount-specific exportkeys
setting?
pkg/gitconfig/configs.go
Outdated
if cfg == nil { | ||
continue | ||
} | ||
if cfg.vars == nil { | ||
continue | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if cfg == nil { | |
continue | |
} | |
if cfg.vars == nil { | |
continue | |
} | |
if cfg == nil || cfg.vars == nil { | |
continue | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we don't even have to check for cfg.vars == nil
. range handles that properly.
1632f28
to
4c47698
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Maybe just 2 last changes!
Correct the doc in:
https://github.com/gopasspw/gopass/blob/dcea35c0c97ead9529da76797eba24d3ed08bdab/docs/commands/config.md
And add the store flag to the config
command:
gopass/internal/action/commands.go
Lines 157 to 168 in dcea35c
{ | |
Name: "config", | |
Usage: "Display and edit the configuration file", | |
ArgsUsage: "[key [value]]", | |
Description: "" + | |
"This command allows for easy printing and editing of the configuration. " + | |
"Without argument, the entire config is printed. " + | |
"With a single argument, a single key can be printed. " + | |
"With two arguments a setting specified by key can be set to value.", | |
Action: s.Config, | |
BashComplete: s.ConfigComplete, | |
}, |
Ah, it seems a few extra documentation places needs updates too:
|
4c47698
to
702be31
Compare
@AnomalRoil Thanks again. Updated all of these. |
The following didn't work for me:
It displayed the two lines instead of hiding the first line. |
Ah, it seems the problem is actually in the migration path, since in the old |
702be31
to
d8ab89a
Compare
Ack. Fixed that. |
| `mounts.path` | `string` | Path to the root store. | `$XDG_DATA_HOME/gopass/stores/root` | | ||
| `core.showsafecontent` | `bool` | Only output *safe content* (i.e. everything but the first line of a secret) to the terminal. Use *copy* (`-c`) to retrieve the password in the clipboard, or *force* (`-f`) to still print it. | `false` | | ||
| `age.usekeychain` | `bool` | Use the OS keychain to cache age passphrases. | `false` | | ||
| `domain-alias.<from>` | `string` | Alias from domain to the string value of this entry. | `` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still holds I guess ^
`` isn't valid markdown on GH.
I wonder how the migration path would be for old config files that still contain legacy options in their YAML:
and others |
This commit adds yet another config handler for gopass. It is based on the format used by git itself. This has the potential to address a lot of long standing issues, but it also causes a lot of changes to how we handle configuration, so bugs are inevitable. Fixes gopasspw#1567 Fixes gopasspw#1764 Fixes gopasspw#1819 Fixes gopasspw#1878 Fixes gopasspw#2387 Fixes gopasspw#2418 RELEASE_NOTES=[BREAKING] New config format based on git config. Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org> Co-authored-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> address comments Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
d8ab89a
to
bf8bd27
Compare
These old configs will just be caried over with the |
This PR adds a new config format - again. This time it's based on git's very own "gitconfig" format. Unfortunately it's not entirely trivial and to date there seem to be no git config handlers in pure Go. All I've found were shelling out to the git binary (which does make sense, as most of the options do have default values that only the binary would know about).
But I still think this format is best suited for our use case since it does combine human and machine accessibility with the right amount of flexibility.
WARNING: This will certainly break some things! The current config handling is so deeply wired in and mixed with our (ab-)use of the
context
package that I'm unlikely to catch every possible breakage on my own. Our users will have to help testing this. Either before it's released or afterwards. But the upshot is that this has the potential to allow us to resolve at least half a dozen outstanding issues and remove quite a bit of legacy from the codebase (more so once we drop the config backwards compatability layer). We could even consider adopting the parser for the secrets themselves in the future.autosync=False
#2387ctxutil
to option structs where feasible #1798gopass show
#1764Fixes #1567
Fixes #1764
Fixes #1819
Fixes #1878
Fixes #2387
Fixes #2408
Fixes #2418
Signed-off-by: Dominik Schulz dominik.schulz@gauner.org