mirror of https://git.jolheiser.com/git-age
chore: update readme and renormalize on init
Signed-off-by: jolheiser <john.olheiser@gmail.com>main
parent
1143ef4bfd
commit
26b581b5db
|
@ -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.**
|
> 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`
|
1. Install `git-age` in your `PATH`
|
||||||
2. `git age init`
|
2. `git age init`
|
||||||
|
@ -18,7 +18,9 @@ Echoed from the original project:
|
||||||
- `git age ident key.txt`
|
- `git age ident key.txt`
|
||||||
- `git age ident ssh`
|
- `git age ident ssh`
|
||||||
4. Set up your config ([example](.git-age.yaml))
|
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
|
## Decrypting an existing repository
|
||||||
|
|
||||||
|
|
20
cmd/init.go
20
cmd/init.go
|
@ -2,7 +2,9 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -41,6 +43,9 @@ func actionInit(ctx *cli.Context) error {
|
||||||
|
|
||||||
cfg, err := LoadConfig()
|
cfg, err := LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if errors.Is(err, fs.ErrNotExist) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
dir, err := gitBaseDir()
|
dir, err := gitBaseDir()
|
||||||
|
@ -61,13 +66,13 @@ func actionInit(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
cmd := exec.Command(exe, args...)
|
c := exec.Command(exe, args...)
|
||||||
cmd.Stdin = bytes.NewReader(content)
|
c.Stdin = bytes.NewReader(content)
|
||||||
cmd.Stdout = &buf
|
c.Stdout = &buf
|
||||||
if debug {
|
if debug {
|
||||||
cmd.Stderr = os.Stderr
|
c.Stderr = os.Stderr
|
||||||
}
|
}
|
||||||
if err := cmd.Run(); err != nil {
|
if err := c.Run(); err != nil {
|
||||||
if debug {
|
if debug {
|
||||||
fmt.Fprintf(os.Stderr, "could not smudge file: %v\n", err)
|
fmt.Fprintf(os.Stderr, "could not smudge file: %v\n", err)
|
||||||
}
|
}
|
||||||
|
@ -78,8 +83,11 @@ func actionInit(ctx *cli.Context) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer fi.Close()
|
|
||||||
fi.Write(buf.Bytes())
|
fi.Write(buf.Bytes())
|
||||||
|
if err := fi.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd("git", "add", "--renormalize", apn)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}(); err != nil {
|
}(); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue