diff --git a/backend/git.go b/backend/git.go index e5135ea2..24854952 100644 --- a/backend/git.go +++ b/backend/git.go @@ -32,6 +32,7 @@ import ( "github.com/go-git/go-git/v5/plumbing/transport/ssh" "github.com/go-git/go-git/v5/storage/memory" "github.com/kevinburke/ssh_config" + homedir "github.com/mitchellh/go-homedir" "github.com/spf13/pflag" ) @@ -438,6 +439,10 @@ func buildAuths(ctx context.Context, url string) ([]ssh.AuthMethod, error) { idFiles := sshConfig.GetAll(e.Host, "IdentityFile") for _, idFile := range idFiles { + idFile, err := homedir.Expand(idFile) + if err != nil { + continue + } logger := logger.WithField("identity_file", idFile) publicKeyAuth, err := ssh.NewPublicKeysFromFile(e.User, idFile, "") if err == nil { diff --git a/docs/guide/contributing.md b/docs/guide/contributing.md new file mode 100644 index 00000000..a4487d36 --- /dev/null +++ b/docs/guide/contributing.md @@ -0,0 +1,113 @@ +--- +description: Contributing to scrt — how to build from source, run tests, and verify changes locally. +--- + +# Contributing + +- [Prerequisites](#prerequisites) +- [Clone a fork of the Repository](#clone-a-fork-of-the-repository) +- [Build](#build) +- [Run Tests](#run-tests) +- [Install Locally](#install-locally) +- [Lint Docs](#lint-docs) +- [Verify Your Changes](#verify-your-changes) + +## Prerequisites + +- Go >= 1.18 +- Git +- SSH key configured for GitHub (if testing git storage) + +## Clone a fork of the Repository + +```bash +git clone https://github.com/loderunner/scrt.git +``` + +```bash +cd scrt +``` + +## Build + +**Compile without producing a binary** (useful for quick syntax/type checks): + +```bash +go build ./... +``` + +**Build the binary:** + +```bash +go build -o scrt . +``` + +The binary will be at `./scrt` in the repository root. + +## Run Tests + +```bash +go test ./... +``` + +## Install Locally + +**Option A — Replace the Homebrew binary (macOS):** + +```bash +cp scrt /opt/homebrew/bin/scrt +``` + +**Option B — Install to `$GOPATH/bin`:** + +```bash +go install . +``` + +Make sure `$GOPATH/bin` is in your `$PATH`. + +## Lint Docs + +CI runs prettier and eslint on the `docs/` directory. Run the linter locally before pushing: + +```bash +cd docs && npm run lint +``` + +**Auto-fix formatting issues:** + +```bash +cd docs && npx prettier --write . +``` + +## Verify Your Changes + +**Quick smoke test with local storage:** + +```bash +./scrt init --storage=local --password=test --local-path=test.scrt +``` + +```bash +./scrt set --storage=local --password=test --local-path=test.scrt mykey "myvalue" +``` + +```bash +./scrt get --storage=local --password=test --local-path=test.scrt mykey +``` + +**Test with git storage:** + +```bash +./scrt init --storage=git \ + --password=test \ + --git-url=git@github.com:/.git \ + --git-path=store.scrt \ + --verbose +``` + +**Clean up test artifacts:** + +```bash +rm -f test.scrt +```