chore: update readme and renormalize on init

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main
jolheiser 2023-08-03 15:15:28 -05:00
parent 1143ef4bfd
commit 26b581b5db
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
2 changed files with 18 additions and 8 deletions

View File

@ -10,7 +10,7 @@ Echoed from the original project:
>
> 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.**
## Install
## Adding git-age to a new repository
1. Install `git-age` in your `PATH`
2. `git age init`
@ -18,7 +18,9 @@ Echoed from the original project:
- `git age ident key.txt`
- `git age ident ssh`
4. Set up your config ([example](.git-age.yaml))
5. Use git like normal.
5. Add your secrets to `.gitattributes`
`secret.txt diff=git-age filter=git-age`
6. Use git like normal.
## Decrypting an existing repository

View File

@ -2,7 +2,9 @@ package cmd
import (
"bytes"
"errors"
"fmt"
"io/fs"
"os"
"os/exec"
"path/filepath"
@ -41,6 +43,9 @@ func actionInit(ctx *cli.Context) error {
cfg, err := LoadConfig()
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
return nil
}
return err
}
dir, err := gitBaseDir()
@ -61,13 +66,13 @@ func actionInit(ctx *cli.Context) error {
}
var buf bytes.Buffer
cmd := exec.Command(exe, args...)
cmd.Stdin = bytes.NewReader(content)
cmd.Stdout = &buf
c := exec.Command(exe, args...)
c.Stdin = bytes.NewReader(content)
c.Stdout = &buf
if debug {
cmd.Stderr = os.Stderr
c.Stderr = os.Stderr
}
if err := cmd.Run(); err != nil {
if err := c.Run(); err != nil {
if debug {
fmt.Fprintf(os.Stderr, "could not smudge file: %v\n", err)
}
@ -78,8 +83,11 @@ func actionInit(ctx *cli.Context) error {
if err != nil {
return err
}
defer fi.Close()
fi.Write(buf.Bytes())
if err := fi.Close(); err != nil {
return err
}
cmd("git", "add", "--renormalize", apn)
return nil
}(); err != nil {