|
| 1 | +--- |
| 2 | +title: "How to Configure a Gitsign Cache" |
| 3 | +date: 2022-12-05 |
| 4 | +author: Daniel Bevenius |
| 5 | +--- |
| 6 | + |
| 7 | +This post contains the steps for setting up |
| 8 | +[gitsign-credential-cache](https://github.com/sigstore/gitsign/tree/main/cmd/gitsign-credential-cache). |
| 9 | +which is useful if one has to perform multiple commits in short succession, or |
| 10 | +when doing a rebase. |
| 11 | + |
| 12 | +It can be somewhat frustrating to have the browser open for every single |
| 13 | +commit. For these situations a cache can be enabled using the instructions in |
| 14 | +this post. |
| 15 | + |
| 16 | +First install `gitsign-credential-cache` if it is not already installed: |
| 17 | +```console |
| 18 | +$ go install github.com/sigstore/gitsign/cmd/gitsign-credential-cache@latest |
| 19 | +``` |
| 20 | + |
| 21 | +Create a file named `~/.config/systemd/user/gitsign.service`: |
| 22 | +```console |
| 23 | +[Unit] |
| 24 | +Description=Gitsign Credentials Cache |
| 25 | +Documentation=https://github.com/sigstore/gitsign |
| 26 | + |
| 27 | +[Service] |
| 28 | +Type=simple |
| 29 | +ExecStart=%h/go/bin/gitsign-credential-cache |
| 30 | + |
| 31 | +Restart=on-failure |
| 32 | + |
| 33 | +[Install] |
| 34 | +WantedBy=default.target |
| 35 | +``` |
| 36 | +This service can then be enabled using: |
| 37 | +```console |
| 38 | +$ systemctl --user daemon-reload |
| 39 | +$ systemctl --user enable gitsign.service |
| 40 | +Created symlink /home/danielbevenius/.config/systemd/user/default.target.wants/gitsign.service → /home/danielbevenius/.config/systemd/user/gitsign.service. |
| 41 | +``` |
| 42 | +And we can start it manually using: |
| 43 | +```console |
| 44 | +$ systemctl --user start gitsign.service |
| 45 | +``` |
| 46 | + |
| 47 | +Check that it has started successfully: |
| 48 | +```console |
| 49 | +$ systemctl --user status gitsign.service |
| 50 | +● gitsign.service - Gitsign Credentials Cache |
| 51 | + Loaded: loaded (/home/danielbevenius/.config/systemd/user/gitsign.service; enabled; vendor preset: disabled) |
| 52 | + Active: active (running) since Mon 2022-11-28 11:27:47 CET; 2min 35s ago |
| 53 | + Docs: https://github.com/sigstore/gitsign |
| 54 | + Main PID: 177444 (gitsign-credent) |
| 55 | + CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/gitsign.service |
| 56 | + └─ 177444 /home/danielbevenius/go/bin/gitsign-credential-cache |
| 57 | + |
| 58 | +Nov 28 11:27:47 localhost.localdomain systemd[1295]: Started Gitsign Credentials Cache. |
| 59 | +Nov 28 11:27:47 localhost.localdomain gitsign-credential-cache[177444]: /home/danielbevenius/.cache/.sigstore/gitsig> |
| 60 | +``` |
| 61 | +And we then need to add the following environment variable: |
| 62 | +```console |
| 63 | +$ export GITSIGN_CREDENTIAL_CACHE=~/.cache/.sigstore/gitsign/cache.sock |
| 64 | +``` |
| 65 | +After this we should be able to commit a first time and have our credentials |
| 66 | +stored. Subsequent commits will then be made without a browser "popup". |
| 67 | + |
0 commit comments