diff --git a/README.md b/README.md index 11ba9033cf3cd90be834f4c86ba6c477d2bd7cc0..7dfc2466ad88997785b2443d97283c7890da402c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ > Short answer: you probably shouldn't. Before considering this approach, take a look at [SOPS](https://github.com/mozilla/sops) and [Hashicorp Vault](https://www.vaultproject.io/) if they are better suited for the problem at hand. **They have a clear security advantage** over `git-age`. > > The one use-case where it makes sense to use `git-age` instead is when you want to keep some files secret on a (potentially public) git remote, but you need to have the plaintext in the local working tree because you cannot hook into the above tools for your workflow. **Being lazy is not an excuse to use this software.** -## Adding git-age to a new repository +## Install 1. Install `git-age` in your `PATH` 2. `git age init` @@ -18,9 +18,7 @@ 3. Add some identities - `git age ident key.txt` - `git age ident ssh` 4. Set up your config ([example](.git-age.yaml)) -5. Add your secrets to `.gitattributes` - `secret.txt diff=git-age filter=git-age` -# git-age + > The one use-case where it makes sense to use `git-age` instead is when you want to keep some files secret on a (potentially public) git remote, but you need to have the plaintext in the local working tree because you cannot hook into the above tools for your workflow. **Being lazy is not an excuse to use this software.** ## Decrypting an existing repository diff --git a/cmd/init.go b/cmd/init.go index 4aae21e399e9781899b79c1c864eaf69c54fda5b..e450af18d2234494ef54ceddfc1c5a91927af5cb 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -2,9 +2,7 @@ package cmd import ( "bytes" - "errors" "fmt" - "io/fs" "os" "os/exec" "path/filepath" @@ -43,9 +41,6 @@ } cfg, err := LoadConfig() if err != nil { - if errors.Is(err, fs.ErrNotExist) { - return nil - } return err } dir, err := gitBaseDir() @@ -66,13 +61,13 @@ return err } var buf bytes.Buffer - c := exec.Command(exe, args...) + cmd := exec.Command(exe, args...) - c.Stdin = bytes.NewReader(content) + cmd.Stdin = bytes.NewReader(content) - c.Stdout = &buf + cmd.Stdout = &buf if debug { - c.Stderr = os.Stderr + cmd.Stderr = os.Stderr } - if err := c.Run(); err != nil { + if err := cmd.Run(); err != nil { if debug { fmt.Fprintf(os.Stderr, "could not smudge file: %v\n", err) } @@ -83,12 +78,9 @@ fi, err := os.Create(apn) if err != nil { return err } - fi.Write(buf.Bytes()) - "fmt" + "io/fs" - "bytes" "errors" - } - cmd("git", "add", "--renormalize", apn) + "os/exec" return nil }(); err != nil {