diff --git a/.codespellrc b/.codespellrc
index 322ab3609365f7d28465ca067b876c3da4387545..991380a4616f33d4f0dd6a8e093a9c3db961ecb6 100644
--- a/.codespellrc
+++ b/.codespellrc
@@ -1,5 +1,5 @@
[codespell]
-skip = .git,.venv,*.svg,package-lock.json,go.mod,go.sum,./misc/completion/*
+skip = .git,.venv,*.svg,*/package-lock.json,go.mod,go.sum,./misc/completion/*
# ot,fo,te - used as short variable names
# optionall - OptionAll but codespell is case insensitive
# testing - TestIn
diff --git a/.envrc b/.envrc
index 9b41f79bc0fc46f5304272c29df16814006f05b4..efba7f6ea6e1dee892b0580dddc73897b53f52dc 100644
--- a/.envrc
+++ b/.envrc
@@ -18,3 +18,4 @@ use flake
# files to watch
watch_file .envrc.local
+watch_file flake-hook.bash
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index dca4e756234677259dc9cf72faa63d6a77c42581..48d8a862133206d6df88bc62a4c3b744383d8689 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,3 +1,2 @@
-# These are supported funding model platforms
-
+---
open_collective: git-bug
diff --git a/.github/actions/auto-label/action.yml b/.github/actions/auto-label/action.yml
index e19dce77f1af97fb3676dbf3a95c3a1bf2542023..7ada546a058b9b4c6690134c8bf1546aa4a6774f 100644
--- a/.github/actions/auto-label/action.yml
+++ b/.github/actions/auto-label/action.yml
@@ -1,3 +1,4 @@
+---
name: auto-label
description: manage labels for issues and pull requests
author: git-bug
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index c987ba9b1b32afd4a7428794fd696f2851260571..96268ba633c0262b673c76d86f08fa2d012b2c63 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -1,8 +1,12 @@
+---
name: build-and-test
on:
workflow_call:
+permissions:
+ contents: read
+
jobs:
with-go:
strategy:
@@ -12,10 +16,10 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- name: Check out code
- uses: actions/checkout@v4
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Go ${{ matrix.go-version }}
- uses: actions/setup-go@v5
+ uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
with:
go-version: ${{ matrix.go-version }}
@@ -42,12 +46,12 @@ jobs:
working-directory: webui
steps:
- name: Setup Node.js ${{ matrix.node-version }}
- uses: actions/setup-node@v4
+ uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ matrix.node-version }}
- name: Check out code
- uses: actions/checkout@v4
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install
run: make install
@@ -57,3 +61,17 @@ jobs:
- name: Test
run: make test
+
+ with-nix:
+ strategy:
+ matrix:
+ platform: [ubuntu-latest, macos-latest]
+ runs-on: ${{ matrix.platform }}
+ steps:
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+
+ - uses: DeterminateSystems/nix-installer-action@21a544727d0c62386e78b4befe52d19ad12692e3 # v17
+
+ - uses: nicknovitski/nix-develop@9be7cfb4b10451d3390a75dc18ad0465bed4932a # v1.2.1
+
+ - run: nix flake check
diff --git a/.github/workflows/lifecycle.yml b/.github/workflows/lifecycle.yml
index 6fe853a6268340e814aa4261a75d60e4aa166d82..1d06ebd40b0fded7d5f2bed88154759a84b6c7bc 100644
--- a/.github/workflows/lifecycle.yml
+++ b/.github/workflows/lifecycle.yml
@@ -1,3 +1,4 @@
+---
name: lifecycle
on:
@@ -45,13 +46,13 @@ jobs:
issues: write
pull-requests: write
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: |
.github/actions/auto-label
- name: "restore cache: node modules"
- uses: actions/cache@v4
+ uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: .github/actions/auto-label/node_modules
key: auto-label-${{ runner.os }}-${{ hashFiles('.github/actions/auto-label/package-lock.json') }}
@@ -153,7 +154,7 @@ jobs:
steps:
- name: "inactivity check: 90 days"
- uses: actions/stale@v9
+ uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with:
days-before-close: -1
days-before-stale: 90
@@ -171,7 +172,7 @@ jobs:
${{ env.PR_MESSAGE_DETAILS }}
- name: "inactivity check: 180 days"
- uses: actions/stale@v9
+ uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9.1.0
with:
days-before-close: -1
days-before-stale: 180
@@ -179,9 +180,10 @@ jobs:
labels-to-remove-when-stale: lifecycle/idle
only-labels: lifecycle/idle
stale-issue-label: lifecycle/dormant
+ stale-issue-message: |-
Pinging maintainers. This issue has been inactive for 180 days.
${{ env.ISSUE_MESSAGE_DETAILS }}
stale-pr-label: lifecycle/dormant
- stale-pr-message: |
+ stale-pr-message: |-
Pinging maintainers. This pull request has been inactive for 180 days.
${{ env.PR_MESSAGE_DETAILS }}
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
deleted file mode 100644
index 542d7df8a00aa3504c89b6bb961ac3105cfda8ee..0000000000000000000000000000000000000000
--- a/.github/workflows/lint.yml
+++ /dev/null
@@ -1,63 +0,0 @@
-name: lint
-
-on:
- workflow_call:
-
-jobs:
- filter:
- name: filter
- runs-on: ubuntu-latest
- outputs:
- golang: ${{ steps.filter.outputs.golang }}
- golang_files: ${{ steps.filter.outputs.golang_files }}
- steps:
- - uses: actions/checkout@v4
- - uses: dorny/paths-filter@v3
- id: filter
- with:
- list-files: shell
- filters: |
- golang:
- - added|modified: '**/*.go'
- - added|modified: '/go.sum'
- - added|modified: '/go.mod'
-
- codeql:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
- with:
- # We must fetch at least the immediate parents so that if this is
- # a pull request then we can checkout the head.
- fetch-depth: 2
-
- - run: git checkout HEAD^2
- if: ${{ github.event_name == 'pull_request' }}
-
- spelling:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Check spelling
- uses: codespell-project/actions-codespell@v2
-
- go:
- runs-on: ubuntu-latest
- needs:
- - filter
- if: needs.filter.outputs.golang == 'true'
- steps:
- - name: Install Go
- uses: actions/setup-go@v5
- with:
- go-version: 1.24.2
-
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Check Code Formatting
- run: |
- test -z "$(gofmt -d ${{ needs.filter.outputs.golang_files }})" || exit 1
diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml
index 5656011c47d1395ab7d10a397dc24af7872217e3..b6e2aa7753c0e4ef753dc99014134b203a2bf76b 100644
--- a/.github/workflows/presubmit.yml
+++ b/.github/workflows/presubmit.yml
@@ -21,9 +21,6 @@ concurrency:
cancel-in-progress: true
jobs:
- lint:
- uses: ./.github/workflows/lint.yml
-
build-and-test:
uses: ./.github/workflows/build-and-test.yml
secrets: inherit
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e165bc7b92e5be4e68753531ea86e9212c071f27..90104e21bfc7025b78ca284f8b5a0f4d72fdd088 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,3 +1,4 @@
+---
name: Build release binaries
on:
@@ -9,18 +10,28 @@ concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
+permissions:
+ contents: read
+
jobs:
build-release:
runs-on: "ubuntu-latest"
+ permissions:
+ # unfortunately, this is necessary for creating the release. there is a
+ # comnunity discussion tracking a request to implement a more granular
+ # permission that as of writing, has not seen any activity since 2023 [0].
+ #
+ # [0]: https://github.com/orgs/community/discussions/68252
+ contents: write
steps:
+ - name: Check out code
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
+
- name: Set up Go
- uses: actions/setup-go@v5
+ uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
with:
go-version: 1.24.2
- - name: Check out code
- uses: actions/checkout@v4
-
- name: Build
run: make
@@ -35,7 +46,7 @@ jobs:
- name: Build binaries
run: make releases
- - uses: "marvinpinto/action-automatic-releases@latest"
+ - uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.2.1
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
draft: true
diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml
index ed69aed789d7f946a740ce4d8f4d455a41eb9386..5279ae35401f42a3eab15108644ec789ea4fb704 100644
--- a/.github/workflows/scan.yml
+++ b/.github/workflows/scan.yml
@@ -1,10 +1,11 @@
+---
name: scan
on:
push:
- branches: [ master ]
+ branches: [master]
pull_request:
- branches: [ master ]
+ branches: [master]
schedule:
- cron: '0 12 * * 6'
@@ -16,17 +17,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- uses: actions/checkout@v4
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 2
- name: Initialize CodeQL
- uses: github/codeql-action/init@v3
+ uses: github/codeql-action/init@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
with:
languages: go, javascript
- name: Autobuild
- uses: github/codeql-action/autobuild@v3
+ uses: github/codeql-action/autobuild@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v3
+ uses: github/codeql-action/analyze@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml
index 5baf29ba96061d0c9254820cf103da62b4dd9e98..6abf3ed4139ace9b19308b890d80b6ecc8d1303c 100644
--- a/.github/workflows/trunk.yml
+++ b/.github/workflows/trunk.yml
@@ -16,9 +16,6 @@ concurrency:
cancel-in-progress: true
jobs:
- lint:
- uses: ./.github/workflows/lint.yml
-
build-and-test:
uses: ./.github/workflows/build-and-test.yml
secrets: inherit
@@ -29,9 +26,9 @@ jobs:
contents: write
deployments: write
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- - uses: actions/setup-go@v5
+ - uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
with:
go-version: 1.24.2
@@ -39,7 +36,7 @@ jobs:
run: go test -v ./... -bench=. -run=xxx -benchmem | tee output.txt
- name: Store benchmark result
- uses: benchmark-action/github-action-benchmark@v1
+ uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4
with:
tool: 'go'
output-file-path: output.txt
diff --git a/.gitignore b/.gitignore
index d21e45da72721d64cdde82a1a919a4d18812439d..d6eae0b3200d3d6c4ce1c648724d07da53309b05 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,6 @@ coverage.txt
.envrc.local
/.direnv/
!/.envrc
+
+# nix output directory from `nix build` commands
+/result
diff --git a/.pinact.yaml b/.pinact.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..09137ba77b9e6ba58fedd1a72c80d678084eddd2
--- /dev/null
+++ b/.pinact.yaml
@@ -0,0 +1,7 @@
+---
+# yaml-language-server: $schema=https://raw.githubusercontent.com/suzuki-shunsuke/pinact/refs/heads/main/json-schema/pinact.json
+version: 3
+
+ignore_actions:
+ - name: marvinpinto/action-automatic-releases
+ ref: latest
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 4d3fd58aec936fc76bc49860f8bf1da6c5577c10..48125d442fe31cab1e3316f3511fffb3ca7854de 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,99 +1,266 @@
-# Contributing
+# Contributing
:wave: Hey there! Thanks for considering taking the time to contribute to
`git-bug`. This page contains some general guidelines, and instructions for
getting started as a contributor to this project.
-## Get the source code
+
+
+- [Get the source code](#get-the-source-code)
+- [Software requirements](#software-requirements)
+ - [1.0 | Install nix](#10--install-nix)
+ - [2.0 | Enable `nix-command` and `flakes`](#20--enable-nix-command-and-flakes)
+ - [3.0 | Install and configure `direnv`](#30--install-and-configure-direnv)
+- [4.0 | Post-installation tasks](#40--post-installation-tasks)
+ - [4.1 | Open a new shell](#41--open-a-new-shell)
+- [Useful development commands](#useful-development-commands)
+- [Submitting changes](#submitting-changes)
+
+
+
+## Get the source code
Clone this repository to your system in a way you're comfortable with. Below, we
-show a command that [clones the repository][how-to-clone] using SSH, and places
-it in `~/code/git-bug`.
+show a command that clones the repository using SSH, and places it in
+`~/code/git-bug`.
```
git clone git@github.com:git-bug/git-bug ~/code/git-bug
```
-> [!IMPORTANT]
+> [!TIP]
> If you wish to clone the repository to another location on disk, change
-> `~/code/git-bug` to your desired path. The rest of this documentation will
-> refer to `~/code/git-bug` in all instances, so make sure you change them
-> there, too.
+> `~/code/git-bug` to your desired path (e.g. your current directory can be used
+> with `.` or by omitting the path argument). The rest of this documentation
+> will refer to `~/code/git-bug` in all instances, so make sure you change them
+> there to match the location you've cloned the repository.
-## Software recommendations
+## Software requirements
-While you can install Golang and hack on this project on your own, you're likely
-to have a better experience if you install the following software.
+This repository uses `nix` to provide a consistent development environment,
+ensuring that each contributor has the same revision of each dependency and tool
+installed. It is **strongly** encouraged to use `nix` when contributing to
+`git-bug` to remove the "it works on my machine" class of errors, and ensure you
+have a smoother experience passing the CI pipelines (wrt formatting and such).
-### `nix` (_recommended_)
+While you can manually install the [tools and packages we use](./flake.nix) and
+hack on this project on your own, you will miss out on the hermeticity and
+standardization that our development shell provides. You may end up fighting
+with failing CI pipelines more often, or have to figure out how to perform
+various tasks on your own. Using the development shell ensures you always have
+every tool you need to contribute to `git-bug`, and that each tool is always
+configured correctly.
-[`nix`][install/nix] is used in this repository to provide a common development
-shell, with a complete set of the appropriate version of the tools used to work
-on `git-bug`.
+Because of this, we encourage all contributors to follow the documentation below
+to install the dependencies for the development shell.
-You can install `nix` by following [the official instructions][install/nix], but
-we recommend adding some additional flags in order to enable some (technically
-experimental, but largely stable) configuration options:
+> [!NOTE]
+> In the future, we will provide a container image with `nix` pre-installed and
+> everything configured to get you started. This will be able to be pulled like
+> any other image, and will be made compatible with VSCode's "devcontainer"
+> feature and GitHub Codespaces.
+>
+> For more information, see the [tracking issue][issue/1364].
-```
-curl -L https://nixos.org/nix/install | sh -s -- --daemon --nix-extra-conf-file <( \
-cat << EOF | sed -e 's/^ *//'
- experimental-features = nix-command flakes
-EOF
-)
-```
+______________________________________________________________________
-> [!TIP]
-> Make sure you read the prompts from the installation script carefully. After
-> installation, you'll need to start a new shell.
+### 1.0 | Install nix
+
+To install `nix`, you can follow [the official instructions][install/nix].
+
+We recommend following the instructions for `multi-user mode` where applicable,
+instead of `single-user mode`.
+
+> [!IMPORTANT]
+> The rest of this document assumes you have successfully installed `nix`.
+
+______________________________________________________________________
+
+### 2.0 | Enable `nix-command` and `flakes`
+
+`nix-command` and `flakes` are two optional configuration properties that we
+depend on in order to provide the development shell. You'll need to make sure
+that these are enabled.
-### `direnv` (_recommended_)
+
+NixOS
-[`direnv`][install/direnv] is used to automatically activate the development
-shell (because of the `.envrc` in the root of this repository).
+Add the following to your system configuration:
-#### With `nix`
+
+
+
+
+
+Other
+
+Add the following to `~/.config/nix.conf` or `/etc/nix/nix.conf`:
+
+
+experimental-features = nix-command flakes
+
+
+
> [!IMPORTANT]
-> If you are not comfortable with `nix`, we recommend [installing `direnv`
-> without nix][install/install-direnv-without-nix].
+> The rest of this document assume you have enabled these options.
-```
+______________________________________________________________________
+
+### 3.0 | Install and configure `direnv`
+
+[`direnv`][install/direnv] can be used to automatically activate the development
+shell (using [`//:.envrc`][envrc]). It can be installed either with `nix`, or
+independently.
+
+
+With nix(suggested for users new to nix)
+
+
-There's a second step that is critical -- be sure to [configure your
-shell][install/direnv/shell].
+Next, run the following commands to apply the **optional** configuration for
+direnv. Be sure to change references to `~/code/git-bug` if you have cloned the
+repository somewhere else.
-#### Without `nix`
+Create a configuration file for direnv
-You can install `direnv` by following [the official
-instructions][install/direnv]. There's a second step that is critical -- be sure
-to [configure your shell][install/direnv/shell].
+
touch ~/.config/direnv/direnv.toml
-After installation, you'll need to start a new shell.
+Disable the warning for shells with longer load times
-##### direnv configuration (_recommended_)
+_This is optional, but recommended, as it helps reduce visual clutter._
-If you install `direnv`, it is recommended to set the following configuration
-options to improve your user experience. At the time of writing, these go in
-`~/.config/direnv/direnv.toml`.
+
+nix run nixpkgs\#dasel -- -r toml -f ~/.config/direnv/direnv.toml \
+ put -t int -v 0 ".global.warn_timeout"
+
-This configuration, namely, the `whitelist.exact` property, will ensure that
-`direnv` always automatically sources the `.envrc` in this repository.
+Disable printing of the environment variables that change
-```
-hide_env_diff = true
-warn_timeout = 0
+_This is optional, but recommended, as it helps reduce visual clutter._
-[whitelist]
-exact = ["~/code/git-bug/.envrc"]
-```
+
+nix run nixpkgs\#dasel -- -r toml -f ~/.config/direnv/direnv.toml \
+ put -t bool -v true ".global.hide_env_diff"
+
-> [!IMPORTANT]
-> Make sure you change the `~/code/git-bug` portion of the string to the
-> appropriate path (the path that you cloned this repository to on your system).
+Automatically activate the development shell
-[install/nix]: https://nix.dev/install-nix
+_This is optional, but strongly recommended._
+
+
+nix run nixpkgs\#dasel -- -r toml -f ~/.config/direnv.toml \
+ put -v "~/code/git-bug/.envrc" ".whitelist.exact[]"
+
+
+Alternatively, simply run `direnv allow` after moving into the repository for
+the first time.
+
+> **IMPORTANT** If you choose not to allow the shell to be automatically
+> activated, you will need to type `nix develop` every time you want to activate
+> it, and this will swap you into bash and change your prompt. You'll have a far
+> better experience allowing `direnv` to automatically manage activation and
+> deactivation.
+
+Configure your shell
+
+This final step is crucial -- be sure to
+[configure your shell][install/direnv/shell] for direnv.
+
+
+
+
+Using home-manager
+
+
+
+
+
+______________________________________________________________________
+
+## 4.0 | Post-installation tasks
+
+Congratulations! If you've reached this section of the documentation, chances
+are that you have a working development environment for contributing to this
+repository. Read below for some additional tasks you should complete.
+
+### 4.1 | Open a new shell
+
+In order for the installation to take effect, you will need to open a new shell.
+It is recommended to do this and complete the test (described below) prior to
+closing the shell you ran the installation script in, just in case you run into
+issues and need to refer to any output it provided.
+
+______________________________________________________________________
+
+## Useful development commands
+
+- `make build` - build `git-bug` and output the binary at `./git-bug`
+ - `make build/debug` - build a debugger-friendly binary
+- `make install` - build `git-bug`, and install it to `$GOPATH/bin`
+- `nix fmt` - format everything (configured in [`//:treefmt.nix`][treefmt])
+ - `nix fmt ` to restrict the scope to given directories or files
+ - _see `nix fmt --help` for more information_
+- `nix flake check` to run lint/format checks and all tests defined in
+ `//nix/checks`
+- `go generate` - generate cli documentation and shell completion files
+ - this is automatically executed by many `make` targets, e.g. `make build`
+- `go test ./commands -update` - update golden files used in tests
+ - this is _required_ when changing the output of CLI commands, if the files in
+ `//commands/testdata/...` do not match the new output format
+- `pinact` to pin any newly-added github action libraries
+ - `pinact upgrade` to upgrade action libraries
+
+> [!NOTE]
+> There is an ongoing effort to simplify the commands you need to call in our
+> environment, with a trend toward `nix`, while `make` may continue to be
+> supported for common workflows (e.g. building a release binary).
+
+## Submitting changes
+
+You can submit your changes in the typical fork-based workflow to this
+repository on GitHub. That is: fork this repository, push to a branch to your
+repository, and create a pull request.
+
+If you are in the development shell, you have the `gh` command line tool
+available for use with github.
+
+______________________________________________________________________
+
+##### See more
+
+- [An overview of the architecture][doc/design/arch]
+- [Learn about the data model][doc/design/model]
+- [See how to create a new entity][example-entity]
+
+[doc/design/arch]: ./doc/design/architecture.md
+[doc/design/model]: ./doc/design/data-model.md
+[envrc]: ./.envrc
+[example-entity]: ./entity/dag/example_test.go
[install/direnv]: https://github.com/direnv/direnv/blob/master/docs/installation.md
[install/direnv/shell]: https://github.com/direnv/direnv/blob/master/docs/hook.md
+[install/nix]: https://nix.dev/install-nix
+[issue/1364]: https://github.com/git-bug/git-bug/issues/1364
+[treefmt]: ./treefmt.nix
diff --git a/INSTALLATION.md b/INSTALLATION.md
new file mode 100644
index 0000000000000000000000000000000000000000..d4a2f4571777fbea77054d317475688acea51777
--- /dev/null
+++ b/INSTALLATION.md
@@ -0,0 +1,263 @@
+
+
+# Installation Guide
+
+`git-bug` is distributed as a single binary, and is available for multiple
+platforms. Follow this document for instructions on how to install `git-bug`,
+and verify your installation.
+
+
+
+- [Download a pre-compiled release binary](#download-a-pre-compiled-release-binary)
+- [Linux](#linux)
+ - [Arch Linux](#arch-linux)
+ - [Nixpkgs](#nixpkgs)
+- [FreeBSD](#freebsd)
+- [MacOS](#macos)
+- [Windows](#windows)
+- [Build from source](#build-from-source)
+- [Verify your installation](#verify-your-installation)
+
+
+
+## Download a pre-compiled release binary
+
+You can download the latest release binary from [the release page][rel/latest],
+making sure to grab the appropriate binary for your system.
+
+Next, rename the binary to `git-bug`, or `git-bug.exe` if you're using Windows.
+
+Finally, place the binary in a directory that's in your `PATH`. That's it! You
+should now have `git-bug` available as a command line tool.
+
+## Linux
+
+`git-bug` is available on a variety of Linux distributions, but how you install
+it depends on your distribution and package manager(s), as there is no standard
+package manager common to all distributions.
+
+### Arch Linux
+
+`git-bug` is available in the [Arch Linux User Repository (AUR)][p/aur].
+
+Below, you'll find a **non-exhaustive** list of commands that use common third
+party tools for installing packages from the AUR.
+
+Using aurutils
+
aur sync git-bug-bin && pacman -Syu git-bug-bin
+
+
+Using yay
+
yay -S git-bug-bin
+
+
+### Nixpkgs
+
+`git-bug` is available via [nixpkgs][p/nix].
+
+Using home-manager
+
+home.package = with pkgs; [
+ git-bug
+];
+
+
+
+Using system configuration
+
+environment.systemPackages = with pkgs; [
+ git-bug
+];
+
+
+
+Using nix profile
+
nix profile install nixpkgs\#git-bug
+
+
+Temporary installation with nix shell
+
+nix shell nixpkgs\#git-bug
+
+
+
+## FreeBSD
+
+`git-bug` is available on FreeBSD through a few different methods.
+
+Using pkg
+
pkg install git-bug
+
+
+Using the ports collection
+
make -C /usr/ports/devel/git-bug install clean
+
+
+## MacOS
+
+`git-bug` is shipped via [**Homebrew**][brew.sh]:
+
+```
+brew install git-bug
+```
+
+## Windows
+
+`git-bug` is shipped via `scoop`:
+
+```
+scoop install git-bug
+```
+
+## Build from source
+
+You can also build `git-bug` from source, if you wish. You'll need the following
+dependencies:
+
+- `git`
+- `go`
+- `make`
+
+Ensure that the `go` binary directory (`$GOPATH/bin`) is in your `PATH`. It is
+recommended to set this within your shell configuration file(s), such as
+`~/.zprofile` or `~/.bashrc`.
+
+```
+export PATH=$PATH:$(go env GOROOT)/bin:$(go env GOPATH)/bin
+```
+
+> [!NOTE]
+> The commands below assume you do not want to keep the repository on disk, and
+> thus clones the repository to a new temporary directory and performs a
+> lightweight clone in order to reduce network latency and data transfer.
+>
+> As a result, the repository cloned during these steps will not contain the
+> full history. If that is important to you, clone the repository using the
+> method you prefer, check out your preferred revision, and run `make install`.
+
+**First, create a new repository on disk:**
+
+```
+cd $(mktemp -d) && git init .
+```
+
+**Next, set the remote to the upstream source:**
+
+```
+git remote add origin git@github.com:git-bug/git-bug.git
+```
+
+Next, choose whether you want to build from a release tag, branch, or
+development head and expand the instructions below.
+
+Build from a release tag
+
+First, list all of the tags from the repository (we use `sed` in the command
+below to filter out some unnecessary visual noise):
+
+
+git ls-remote origin refs/tags/\* | sed -e 's/refs\/tags\///'
+
+The --no-tags flag might seem out of place, since we are
+fetching a tag, but it isn't -- the reason we use this is avoid fetching other
+tags, in case you have fetch.pruneTags enabled in your global
+configuration, which causes git to fetch all tags.
+
+
+Next, check out the tag, replacing REPLACE-ME with the tag you
+selected:
+
+
+git checkout REPLACE-ME
+
+
+Finally, run the install target from //:Makefile:
+
+
+make install
+
+
+This will build git-bug and place it in your Go binary directory.
+
+
+
+
+
+Build the unstable development HEAD
+
+
+First, fetch the most recent commit for the default branch:
+
+
+
+Finally, run the install target from //:Makefile:
+
+
+make install
+
+
+This will build git-bug and place it in your Go binary directory.
+
+
+
+## Verify your installation
+
+To verify that `git-bug` was installed correctly, you can run the following
+command. If you see output similar to what's shown below (and without any
+errors), you're all set!
+
+```
+git bug version
+```
+
+______________________________________________________________________
+
+##### See more
+
+- [Documentation home][docs/home]
+
+[brew.sh]: https://brew.sh
+[docs/home]: ./doc
+[p/aur]: https://aur.archlinux.org/packages/git-bug-bin
+[p/nix]: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/applications/version-management/git-bug/default.nix
+[rel/latest]: https://github.com/git-bug/git-bug/releases/latest
diff --git a/Makefile b/Makefile
index 404612dc34ab673a276c2714a44813f5b8087e6b..5d10469e0045634c44e55f9f98a2bbe2cf114bc3 100644
--- a/Makefile
+++ b/Makefile
@@ -9,19 +9,29 @@ ifeq ($(UNAME_S),Darwin)
XARGS:=xargs
endif
+SYSTEM=$(shell nix eval --impure --expr 'builtins.currentSystem' --raw 2>/dev/null || echo '')
+
COMMANDS_PATH:=github.com/git-bug/git-bug/commands
LDFLAGS:=-X ${COMMANDS_PATH}.GitCommit="${GIT_COMMIT}" \
-X ${COMMANDS_PATH}.GitLastTag="${GIT_LAST_TAG}" \
-X ${COMMANDS_PATH}.GitExactTag="${GIT_EXACT_TAG}"
+.PHONY: list-checks
+list-checks:
+ @if test -z "$(SYSTEM)"; then echo "unable to detect system. is nix installed?" && exit 1; fi
+ @printf "Available checks for $(SYSTEM) (run all with \`nix flake check\`):\n"
+ @nix flake show --json 2>/dev/null |\
+ dasel -r json -w plain '.checks.x86_64-linux.keys().all()' |\
+ xargs -I NAME printf '\t%-20s %s\n' "NAME" "nix build .#checks.linux.NAME"
+
.PHONY: build
build:
go generate
go build -ldflags "$(LDFLAGS)" .
-# produce a build debugger friendly
-.PHONY: debug-build
-debug-build:
+# produce a debugger-friendly build
+.PHONY: build/debug
+build/debug:
go generate
go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" .
diff --git a/README.md b/README.md
index 3538234586cd37753064b6e6a3661c67e24d1c97..4c01c488915d14d7ed8e7688789b6734009aa511 100644
--- a/README.md
+++ b/README.md
@@ -1,336 +1,140 @@
-
-
-
-
git-bug
-
-[](#backers)
-[](#sponsors)
-[](http://www.gnu.org/licenses/gpl-3.0)
-[](https://godoc.org/github.com/git-bug/git-bug)
-[](https://goreportcard.com/report/github.com/git-bug/git-bug)
-[](https://gitter.im/the-git-bug/Lobby)
-
-
-
-`git-bug` is a bug tracker that:
-
-- **is fully embedded in git**: you only need your git repository to have a bug tracker
-- **is distributed**: use your normal git remote to collaborate, push and pull your bugs!
-- **works offline**: in a plane or under the sea? Keep reading and writing bugs!
-- **prevents vendor lock-in**: your usual service is down or went bad? You already have a full backup.
-- **is fast**: listing bugs or opening them is a matter of milliseconds
-- **doesn't pollute your project**: no files are added in your project
-- **integrates with your tooling**: use the UI you like (CLI, terminal, web) or integrate with your existing tools through the CLI or the GraphQL API
-- **bridges to other bug trackers**: use [bridges](#bridges) to import and export to other trackers.
-
-## Help needed!
-
-This project has grown bigger than I can handle by myself, especially with a day job. I'm looking for people to help on or maintain part of it:
-- each bridges (go)
-- the terminal UI (go)
-- the web UI (Typescript/React/GraphQL)
-
-Individually, those pieces are not especially complex but doing everything make it hard for me to focus on the core where things get more complicated. If this is useful for you or you just want to join the fun, maybe consider it?
-
-## Installation
-
-Pre-compiled binaries
-
-1. Go to the [release page](https://github.com/git-bug/git-bug/releases/latest) and download the appropriate binary for your system.
-2. Copy the binary anywhere in your $PATH
-3. Rename the binary to `git-bug` (or `git-bug.exe` on windows)
-
-That's all !
-
-
-
-Windows packages
-
-* [Scoop](https://github.com/ScoopInstaller/Main/blob/master/bucket/git-bug.json)
- ```
- scoop install git-bug
- ```
-
-
-
-Linux packages
-
-* [Archlinux (AUR)](https://aur.archlinux.org/packages/?K=git-bug)
-* [NixOS](https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/version-management/git-and-tools/git-bug/default.nix#L31)
-
-
-
-macOS packages
-
-* [Homebrew](https://formulae.brew.sh/formula/git-bug)
- ```
- brew install git-bug
- ```
-
-
-
-FreeBSD package/port
-
-Install via the package manager
- ```
- pkg install git-bug
- ```
-
-Or from the ports collection
- ```
- cd /usr/ports/devel/git-bug && make install clean
- ```
-
-
-
-Compile from git (unstable)
-
-```shell
-git clone https://github.com/git-bug/git-bug.git
-cd git-bug
-make install
-```
-
-If it's not done already, add the golang binary directory in your PATH:
-
-```bash
-export PATH=$PATH:$(go env GOROOT)/bin:$(go env GOPATH)/bin
-```
-
-
-
-## Workflows
-
-There are multiple ways to use `git-bug`:
-
-Native workflow
-
-
-
-
-This is the pure `git-bug` experience. In a similar fashion as with code, use `git bug push` and `git bug pull` to push and pull your bugs between git remotes and collaborate with your teammate.
-
-
-
-Bridge workflow
-
-
-
-
-As `git-bug` has bridges with other bug-trackers, you can use it as your personal local remote interface. Sync with `git bug bridge pull` and `git bug bridge push`, work from your terminal, integrate into your editor, it's up to you. And it works offline !
-
-
-
-Web UI workflow (WIP)
-
-
-
-
-Often, projects needs to have their bug-tracker public and accept editions from anyone facing a problem. To support this workflow, `git-bug` aims to have the web UI accept external OAuth authentication and act as a public portal. However the web UI is not up to speed for that yet. Contribution are very much welcome!
+
-
+# git-bug: a decentralized issue tracker
-## CLI usage
+[![Build Status][ci/badge]][ci/url]
-Create a new identity:
+[![Backers on Open Collective][backers/badge]][oc]
+[![Sponsors on Open Collective][sponsors/badge]][oc]
+[![GPL v3 License][license/badge]][license/url]
+[![GoDoc][godoc/badge]][godoc/url]
+[![Go Report Card][report-card/badge]][report-card/url]
+[![Matrix][matrix/badge]][matrix/url]
-```
-git bug user create
-```
+[Issues] - [Documentation][doc] - [Feedback][discuss]
-Create a new bug:
-
-```
-git bug add
-```
-
-Your favorite editor will open to write a title and a message.
-
-You can push your new entry to a remote:
-```
-git bug push []
-```
-
-And pull for updates:
-```
-git bug pull []
-```
-
-List existing bugs:
-```
-git bug ls
-```
-
-Filter and sort bugs using a [query](doc/queries.md):
-```
-git bug ls "status:open sort:edit"
-```
-
-Search for bugs by text content:
-```
-git bug ls "foo bar" baz
-```
-
-You can now use commands like `show`, `comment`, `open` or `close` to display and modify bugs. For more details about each command, you can run `git bug --help` or read the [command's documentation](doc/md/git-bug.md).
-
-## Interactive terminal UI
-
-An interactive terminal UI is available using the command `git bug termui` to browse and edit bugs.
-
-
-
-## Web UI
-
-You can launch a rich Web UI with `git bug webui`.
-
-
-
-
-
-
-
-
-
-This web UI is entirely packed inside the same go binary and serve static content through a localhost http server.
-
-The web UI interact with the backend through a GraphQL API. The schema is available [here](api/graphql/schema).
-
-## Bridges
-
-β : working π : partial implementation β: not working
-
-### Importer implementations
-
-| | Github | Gitlab | Jira | Launchpad |
-|-------------------------------------------------|:------:|:------:|:----:|:---------:|
-| **incremental** (can import more than once) | β | β | β | β |
-| **with resume** (download only new data) | β | β | β | β |
-| **identities** | π | π | π | π |
-| **bugs** | β | β | β | π |
-| **board** | β | β | β | β |
-| **media/files** | β | β | β | β |
-| **automated test suite** | β | β | β | β |
-
-### Exporter implementations
-
-| | Github | Gitlab | Jira | Launchpad |
-|--------------------------|:------:|:------:|:----:|:---------:|
-| **identities** | π | π | π | π |
-| **bug** | β | β | β | β |
-| **board** | β | β | β | β |
-| **automated test suite** | β | β | β | β |
-
-#### Bridge usage
-
-Interactively configure a new github bridge:
-
-```bash
-git bug bridge new
-```
-
-Or manually:
-
-```bash
-git bug bridge new \
- --name= \
- --target=github \
- --url=https://github.com/git-bug/git-bug \
- --login= \
- --token=
-```
-
-Import bugs:
-
-```bash
-git bug bridge pull []
-```
-
-Export modifications:
-
-```bash
-git bug bridge push []
-```
-
-Deleting a bridge:
-
-```bash
-git bug bridge rm []
-```
+
-## Internals
+## Overview
-Interested in how it works ? Have a look at the [data model](doc/model.md) and the [internal bird-view](doc/architecture.md).
+[git-bug](https://github.com/git-bug/git-bug) is a standalone, distributed,
+offline-first issue management tool that embeds issues, comments, and more as
+objects in a git repository (_not files!_), enabling you to push and pull them
+to one or more remotes.
-Or maybe you want to [make your own distributed data-structure in git](entity/dag/example_test.go) ?
+
-See also all the [docs](doc).
+- [Overview](#overview)
+- [Key Features](#key-features)
+- [Getting Started](#getting-started)
+- [Our Community](#our-community)
+ - [Backers :star:](#backers-star)
+ - [Sponsors :star2:](#sponsors-star2)
+- [License](#license)
-## Misc
+
-- [Bash, Zsh, fish, powershell completion](misc/completion)
-- [ManPages](doc/man)
+## Key Features
-## Planned features
+- **Native Git Storage:** Manage issues, users, and comments directly within
+ your repository - keeping everything versioned and clutter-free
+- **Distributed & Versioned:** Leverage Gitβs decentralized architecture to work
+ offline and sync seamlessly later
+- **Lightning Fast:** List and search issues in mere _milliseconds_
+- **Third-Party Bridges:** Easily synchronize issues with platforms like GitHub
+ and GitLab [using bridges][doc/usage/bridges]
+- **Flexible Interfaces:** Choose how you interact - via CLI, TUI, or a web
+ browser
+- **Effortless Integration:** Start managing issues your repository with minimal
+ setup
-The [feature matrix](doc/feature_matrix.md) gives a good overview of what is planned, without being exhaustive.
+## Getting Started
-Additional planned feature:
-- webUI that can be used as a public portal to accept user's input
-- inflatable raptor
+- :triangular_flag_on_post: **Install:** Check out
+ [`//:INSTALLATION.md`][doc/install] for step-by-step installation instructions
+ or explore [the latest release][rel/latest] to get started immediately.
+- :page_with_curl: **Explore:** Read [the documentation][doc] to learn how to
+ use `git-bug` effectively
+- :computer: **Contribute:** Interested in hacking on `git-bug`? Head over to
+ [`//:CONTRIBUTING.md`][contrib] and see how you can help shape the project
+- :speech_balloon: **Connect:** Chat with us live on Matrix at
+ [`#git-bug:matrix.org`][matrix/url]
+- :books: **Discuss:** Browse [existing discussions][discuss] or
+ [start a new one][discuss/new] to ask questions and share ideas
-## Contribute
+## Our Community
-PRs accepted. Drop by the [Gitter lobby](https://gitter.im/the-git-bug/Lobby) or the [Matrix room](https://matrix.to/#/#git-bug:matrix.org) for a chat, look at the [feature matrix](doc/feature_matrix.md) or browse the issues to see what is worked on or discussed.
+`git-bug` thrives thanks to the passion of its [contributors], the generosity of
+independent [backers][oc], and the strategic support of our [sponsors][oc]. Each
+of you plays a crucial role in our journey, and we deeply appreciate every
+contribution that helps drive our project forward.
-```shell
-git clone git@github.com:git-bug/git-bug.git
-```
+_[Make a contribution][oc] to support this project and get featured below!_
-You can now run `make` to build the project, or `make install` to install the binary in `$GOPATH/bin/`.
+### Backers :star:
-To work on the web UI, have a look at [the dedicated Readme.](webui/Readme.md)
+
-Some tests for the CLI use golden files, if the output of CLI commands is
-changed, run the following command, then inspect the changed files in
-`commands/testdata/...` to make sure the output text is as expected:
+[![backers][backers/image]][oc]
-```shell
-go test ./commands -update
-```
+
-## Contributors :heart:
+### Sponsors :star2:
-This project exists thanks to all the people who contribute.
-
+
-
-Bridges with other bug-trackers are first-class citizen in `git-bug`. Notably, they are bidirectional, incremental and relatively fast. This means that a perfectly valid way to use `git-bug` is as a sort of remote for Github where you synchronize all the issues of a repository to later read and edit them and then propagate your changes back to Github.
-
-
+
+This has several benefits:
+
+- works offline, including edition
+- browsing is pretty much instant
+- you get to choose the UI you prefer between CLI, interactive TUI or in your
+ browser with the WEBUI
+- you have a near-complete archive of issues locally, embedded in your git
+ repository, in case the external platform becomes inaccessible
+- you are free to move to another platform -- your issues follow wherever your
+ repo goes!
+
+## Supported bridges
+
+We support a number of bridges:
+
+- Jira
+- GitHub
+- GitLab
+- Launchpad
+
+_For a full list of the features enabled for each bridge, see the
+[feature matrix][docs/feature-matrix]._
+
+## Getting started
+
+1. From within a git repository, run `git bug bridge configure` to start the
+ configuration wizard
+2. Choose the type of bridge you want to configure, e.g. `github`
+3. Type a name for the bridge configuration. As you can configure multiple
+ bridges, this name will allow you to choose when there is an ambiguity.
+4. If you already have a repository created on the external platform, and your
+ local git repository has that as a remote, the configuration wizard will
+ automatically detect the URL. Otherwise, please ensure you enter the
+ appropriate URL for the remote project: something like
+ `https://github.com/git-bug/git-bug`
+5. Create an access token. You can either use the interactive token creation,
+ enter it on your own token, or use an existing token if you already have one
+
+That's it! Once you've completed the wizard, you'll have successfully configured
+a bridge.
+
+## Interacting with the bridge
+
+To push issues out to the bridge, run:
+
+```bash
+git bug bridge push [NAME]
+```
+
+To pull and integrate updates for issues from the bridge:
+
+```bash
+git bug bridge pull [NAME]
+```
+
+> [!TIP]
+> See the [CLI documentation][doc/cli/bridge] for more information on the
+> command line arguments and options.
+
+The command line is primarily meant for programmatic usage or to interface with
+`git-bug` with scripts or other tools. For day to day usage, we recommend taking
+a look at [the supported interfaces][docs/usage/interfaces], which include a
+robust TUI and an in-progress Web UI.
+
+______________________________________________________________________
+
+##### See more
+
+- [A bird's-eye view of the internal architecture][docs/design/arch]
+- [A description of the data model][docs/design/model]
+- [An overview of the native interfaces][docs/usage/interfaces]
+- [Filtering query results][docs/usage/filter]
+- [Understanding the workflow models][docs/usage/workflows]
+- :house: [Documentation home][docs/home]
+
+[doc/cli/bridge]: ../md/git-bug_bridge.md
+[docs/design/arch]: ../design/architecture.md
+[docs/design/model]: ../design/data-model.md
+[docs/feature-matrix]: ../feature-matrix.md
+[docs/home]: ../README.md
+[docs/usage/filter]: ./query-language.md
+[docs/usage/interfaces]: ./interfaces.md
+[docs/usage/workflows]: ./workflows.md
diff --git a/doc/usage/workflows.md b/doc/usage/workflows.md
new file mode 100644
index 0000000000000000000000000000000000000000..50477847c414fffb91daa965386355669e925df1
--- /dev/null
+++ b/doc/usage/workflows.md
@@ -0,0 +1,62 @@
+# Workflows
+
+This document provides an overview of different workflows that `git-bug`
+supports.
+
+
+
+## Native workflow
+
+
+
+
+
+This is the pure `git-bug` experience. In a similar fashion as with code, use
+`git bug push` and `git bug pull` to push and pull your bugs between git remotes
+and collaborate with your teammate.
+
+_Recommended reading: [CLI documentation][docs/cli]_
+
+## Bridge workflow
+
+
+
+
+
+`git-bug` supports syncing issues with third-party platforms, such as GitHub,
+GitLab, and Jira. This lets you work on issues offline, editing issues in bulk
+with your preferred editor, or to build an archive of any project's issues --
+it's up to you!
+
+_Recommended reading: [How to use bridges][docs/usage/bridges]_
+
+## Web UI workflow
+
+
+
+
+
+> [!NOTE]
+> The web UI is a work in progress, and is not feature-complete. To utilize
+> `git-bug` to its full potential, we recommend using the TUI or CLI.
+
+Often, projects needs to have their bug-tracker public and accept editions from
+anyone facing a problem. To support this workflow, `git-bug` aims to have the
+web UI accept external OAuth authentication and act as a public portal. However
+the web UI is not up to speed for that yet. Contributions are very much welcome!
+
+______________________________________________________________________
+
+##### See also
+
+- [CLI documentation][docs/cli]
+- [Filtering query results][docs/usage/filter]
+- [How to use bridges][docs/usage/bridges]
+- [Learn about the native interfaces][docs/usage/interfaces]
+- :house: [Documentation home][docs/home]
+
+[docs/cli]: ../md/git-bug.md
+[docs/home]: ../README.md
+[docs/usage/bridges]: ./third-party.md
+[docs/usage/filter]: ./query-language.md
+[docs/usage/interfaces]: ./interfaces.md
diff --git a/entity/dag/example_test.go b/entity/dag/example_test.go
index c9e4f3521f63b638c4e0967c84a7af4ac56a0913..3ffdb4fcfa9bcddc8706c6dd9a2c3237b8009d96 100644
--- a/entity/dag/example_test.go
+++ b/entity/dag/example_test.go
@@ -13,7 +13,7 @@ import (
)
// Note: you can find explanations about the underlying data model here:
-// https://github.com/git-bug/git-bug/blob/master/doc/model.md
+// https://github.com/git-bug/git-bug/blob/master/doc/design/data-model.md
// This file explains how to define a replicated data structure, stored in and using git as a medium for
// synchronisation. To do this, we'll use the entity/dag package, which will do all the complex handling.
diff --git a/flake-hook.bash b/flake-hook.bash
new file mode 100644
index 0000000000000000000000000000000000000000..dde009dd3a5cef27eab427edfc6207c8bc1538d8
--- /dev/null
+++ b/flake-hook.bash
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+# use //:.gitmessage as the commit message template
+git config --local commit.template ".gitmessage"
+
+# use a common, shared file as the default for running git-blame with the
+# `--ignore-revs` flag
+git config --local blame.ignoreRevsFile ".git-blame-ignore-revs"
+
+# enable features.manyFiles, which improves repository performance by setting
+# new values for several configuration options:
+# - `core.untrackedCache = true` enables the untracked cache
+# - `index.version = 4` enables path-prefix compression in the index
+# - `index.skipHash = true` speeds up index writes by not computing a trailing
+# checksum
+git config --local features.manyFiles true
diff --git a/flake.lock b/flake.lock
index 0b0ca7902497efd106e89adb6935c144f5419e33..86a33fcc63c28cb5dbea4610f6aed4dc3a8642c1 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,23 @@
{
"nodes": {
+ "flake-parts": {
+ "inputs": {
+ "nixpkgs-lib": "nixpkgs-lib"
+ },
+ "locked": {
+ "lastModified": 1743550720,
+ "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=",
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "rev": "c621e8422220273271f52058f618c94e405bb0f5",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "flake-parts",
+ "type": "github"
+ }
+ },
"flake-utils": {
"inputs": {
"systems": "systems"
@@ -18,13 +36,29 @@
"type": "github"
}
},
+ "fmt-pkgs": {
+ "locked": {
+ "lastModified": 1744932701,
+ "narHash": "sha256-fusHbZCyv126cyArUwwKrLdCkgVAIaa/fQJYFlCEqiU=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef",
+ "type": "github"
+ }
+ },
"nixpkgs": {
"locked": {
- "lastModified": 1745526057,
- "narHash": "sha256-ITSpPDwvLBZBnPRS2bUcHY3gZSwis/uTe255QgMtTLA=",
+ "lastModified": 1746141548,
+ "narHash": "sha256-IgBWhX7A2oJmZFIrpRuMnw5RAufVnfvOgHWgIdds+hc=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "f771eb401a46846c1aebd20552521b233dd7e18b",
+ "rev": "f02fddb8acef29a8b32f10a335d44828d7825b78",
"type": "github"
},
"original": {
@@ -34,10 +68,28 @@
"type": "github"
}
},
+ "nixpkgs-lib": {
+ "locked": {
+ "lastModified": 1743296961,
+ "narHash": "sha256-b1EdN3cULCqtorQ4QeWgLMrd5ZGOjLSLemfa00heasc=",
+ "owner": "nix-community",
+ "repo": "nixpkgs.lib",
+ "rev": "e4822aea2a6d1cdd36653c134cacfd64c97ff4fa",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-community",
+ "repo": "nixpkgs.lib",
+ "type": "github"
+ }
+ },
"root": {
"inputs": {
+ "flake-parts": "flake-parts",
"flake-utils": "flake-utils",
- "nixpkgs": "nixpkgs"
+ "fmt-pkgs": "fmt-pkgs",
+ "nixpkgs": "nixpkgs",
+ "treefmt-nix": "treefmt-nix"
}
},
"systems": {
@@ -54,6 +106,26 @@
"repo": "default",
"type": "github"
}
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1746216483,
+ "narHash": "sha256-4h3s1L/kKqt3gMDcVfN8/4v2jqHrgLIe4qok4ApH5x4=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "29ec5026372e0dec56f890e50dbe4f45930320fd",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
}
},
"root": "root",
diff --git a/flake.nix b/flake.nix
index 7eb7e802ef2a807588f7db611cca4cb632cee347..421eb86f854c22017a809edc914298d153aa1b72 100644
--- a/flake.nix
+++ b/flake.nix
@@ -4,42 +4,57 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
+ flake-parts.url = "github:hercules-ci/flake-parts";
+
+ treefmt-nix = {
+ url = "github:numtide/treefmt-nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ # A workaround for the currently-broken mdformat packages
+ fmt-pkgs.url = "github:nixos/nixpkgs/b024ced1aac25639f8ca8fdfc2f8c4fbd66c48ef";
};
outputs =
- {
- self,
- flake-utils,
- nixpkgs,
- }:
- flake-utils.lib.eachDefaultSystem (
- system:
- let
- pkgs = nixpkgs.legacyPackages.${system};
- in
- {
- devShell = pkgs.mkShell {
- packages = with pkgs; [
- codespell
- delve
- gh
- git
- go
- golangci-lint
- nixfmt-rfc-style
- nodePackages.prettier
- nodejs
- ];
-
- shellHook = ''
- # Use //:.gitmessage as the commit message template
- ${pkgs.git}/bin/git config --local commit.template ".gitmessage"
-
- # Use a common, shared file as the default for running
- # git-blame with the `--ignore-revs` flag
- ${pkgs.git}/bin/git config --local blame.ignoreRevsFile ".git-blame-ignore-revs"
- '';
+ { nixpkgs, ... }@inputs:
+ let
+ systems = inputs.flake-utils.lib.defaultSystems;
+ in
+ inputs.flake-parts.lib.mkFlake { inherit inputs; } {
+ inherit systems;
+
+ imports = [ inputs.treefmt-nix.flakeModule ];
+
+ perSystem =
+ { pkgs, system, ... }:
+ let
+ fp = inputs.fmt-pkgs.legacyPackages.${system};
+ in
+ {
+ treefmt = import ./treefmt.nix { pkgs = fp; };
+
+ checks = pkgs.lib.attrsets.mapAttrs' (f: _: {
+ name = pkgs.lib.strings.removeSuffix ".nix" f;
+ value = import ./nix/checks/${f} {
+ inherit pkgs;
+ src = ./.;
+ };
+ }) (pkgs.lib.attrsets.filterAttrs (_: t: t == "regular") (builtins.readDir ./nix/checks));
+
+ devShells.default = pkgs.mkShell {
+ packages = with pkgs; [
+ codespell
+ delve
+ gh
+ git
+ go
+ golangci-lint
+ nodejs
+ pinact
+ ];
+
+ shellHook = builtins.readFile ./flake-hook.bash;
+ };
};
- }
- );
+ };
}
diff --git a/main.go b/main.go
index d60bff96b34a46845941dee8af7796b2ccf0cc9b..7a2034baba99d4e9edff6c5b36e4ff683fc26e03 100644
--- a/main.go
+++ b/main.go
@@ -1,5 +1,5 @@
-//go:generate go run doc/gen_docs.go
-//go:generate go run misc/completion/gen_completion.go
+//go:generate go run doc/generate.go
+//go:generate go run misc/completion/generate.go
package main
diff --git a/misc/completion/gen_completion.go b/misc/completion/generate.go
similarity index 99%
rename from misc/completion/gen_completion.go
rename to misc/completion/generate.go
index e2a8cc1bfbdab1129945467600de52181ff3ec40..245c561cde5273913957dda1b717f90a6d497151 100644
--- a/misc/completion/gen_completion.go
+++ b/misc/completion/generate.go
@@ -67,7 +67,7 @@ _git_bug() {
fi
# START PATCH
- # replace in the array ("git","bug", ...) to ("git-bug", ...) and adjust the index in cword
+ # replace in the array ("git","bug", ...) to ("git-bug", ...) and adjust the index in cword
words=("git-bug" "${words[@]:2}")
cword=$(($cword-1))
# END PATCH
diff --git a/misc/diagrams/Readme.md b/misc/diagrams/Readme.md
deleted file mode 100644
index 837a321289c8f9239bf333c9f0949f2eee95081a..0000000000000000000000000000000000000000
--- a/misc/diagrams/Readme.md
+++ /dev/null
@@ -1 +0,0 @@
-The source of those diagrams is on draw.io. Couldn't find a good way to export :(
diff --git a/misc/termui_recording.svg b/misc/termui_recording.svg
deleted file mode 100644
index e1cff4a7132ee2457cd36c60320361fa39894dcf..0000000000000000000000000000000000000000
--- a/misc/termui_recording.svg
+++ /dev/null
@@ -1,43 +0,0 @@
-
\ No newline at end of file
diff --git a/nix/checks/pinact.nix b/nix/checks/pinact.nix
new file mode 100644
index 0000000000000000000000000000000000000000..c032bc9fc927622bc1a2f13d52cf2cad33e0e3d2
--- /dev/null
+++ b/nix/checks/pinact.nix
@@ -0,0 +1,7 @@
+{ pkgs, src }:
+
+pkgs.writeShellApplication {
+ name = "pinact";
+ runtimeInputs = with pkgs; [ pinact ];
+ text = "pinact run --check --verify";
+}
diff --git a/nix/checks/spelling.nix b/nix/checks/spelling.nix
new file mode 100644
index 0000000000000000000000000000000000000000..033b633a02ae89dc1ea793e16fa6456934f05788
--- /dev/null
+++ b/nix/checks/spelling.nix
@@ -0,0 +1,14 @@
+{ pkgs, src }:
+
+pkgs.runCommand "spelling"
+ {
+ inherit src;
+ nativeBuildInputs = with pkgs; [ codespell ];
+ description = "Check for spelling mistakes";
+ }
+ ''
+ pushd $src
+ codespell --check-hidden */**
+ popd
+ touch $out
+ ''
diff --git a/treefmt.nix b/treefmt.nix
new file mode 100644
index 0000000000000000000000000000000000000000..1716d457c04c2a4c84a7416d82e5abe9349c37b0
--- /dev/null
+++ b/treefmt.nix
@@ -0,0 +1,86 @@
+{
+ pkgs,
+ excludes ? [ ],
+ ...
+}:
+{
+ projectRootFile = "flake.nix";
+
+ programs = {
+ gofmt = {
+ enable = true;
+ };
+
+ mdformat = {
+ enable = true;
+
+ package = pkgs.mdformat.withPlugins (
+ p: with p; [
+ # add support for github flavored markdown
+ mdformat-gfm
+ mdformat-gfm-alerts
+
+ # add support for markdown tables
+ mdformat-tables
+
+ # add the following comment before running `nix fmt` to generate a
+ # table of contents in markdown files:
+ #
+ mdformat-toc
+ ]
+ );
+
+ settings = {
+ end-of-line = "lf";
+ number = true;
+ wrap = 80;
+ };
+ };
+
+ nixfmt = {
+ enable = true;
+ strict = true;
+ };
+
+ # this is disabled due to `//webui` not yet being integrated with the flake.
+ # the entire package directory is ignored below in
+ # `settings.global.excludes`.
+ prettier = {
+ enable = false;
+
+ settings = {
+ singleQuote = true;
+ trailingComma = "es5";
+ };
+ };
+
+ shfmt = {
+ enable = true;
+ };
+
+ yamlfmt = {
+ enable = true;
+
+ settings.formatter = {
+ eof_newline = true;
+ include_document_start = true;
+ retain_line_breaks_single = true;
+ trim_trailing_whitespace = true;
+ };
+ };
+ };
+
+ settings.global.excludes =
+ pkgs.lib.lists.unique [
+ "*.graphql"
+ "*.png"
+ "*.svg"
+ "*.txt"
+ "doc/man/*.1" # generated via //doc:generate.go
+ "doc/md/*" # generated via //doc:generate.go
+ "misc/completion/*/*"
+ "webui/*" # not currently supported, //webui is not yet flakeified
+ "Makefile"
+ ]
+ ++ excludes;
+}
diff --git a/webui/Readme.md b/webui/README.md
similarity index 100%
rename from webui/Readme.md
rename to webui/README.md