Trunk-based development manager for a solo developer. https://git.kemitix.net/kemitix/git-next
Find a file
Paul Campbell 7a0247ea03
All checks were successful
Rust / build (push) Successful in 1m13s
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
refactor: get commit log from local repo (step 1)
Avoid using a forge-specific API to get a commit log when the
information is already available locally in the cloned repo through a
generic git command.

The commit adds the new method of getting the commit log and compares it
with the original methods, logging if they match or not.

The updated results are returned only if they match.
2024-05-25 08:10:02 +01:00
.cargo build(forgejo): use rust action 2024-05-17 07:26:07 +01:00
.forgejo/workflows build(forgejo): use rust action 2024-05-17 07:26:07 +01:00
.git-hooks chore: convert project into a cargo workspace 2024-05-11 16:33:18 +01:00
.woodpecker revert: "build(woodpecker): remove redundant build of a builder images" 2024-05-19 07:22:01 +01:00
crates refactor: get commit log from local repo (step 1) 2024-05-25 08:10:02 +01:00
.git-next.toml chore(git-next): add config file 2024-04-09 11:00:29 +01:00
.gitignore fix(#61): Format path to clone into correctly 2024-04-23 18:58:07 +01:00
.rgignore build(woodpecker): TODO checker ignores git hook samples 2024-04-07 17:17:49 +01:00
bacon.toml build(cargo): specify clippy flags in Cargo.toml 2024-05-02 18:52:10 +01:00
Cargo.toml refactor: extract forge-forgejo crate 2024-05-23 19:36:05 +01:00
CHANGELOG.md chore: Release v0.5.2 2024-05-22 21:20:41 +01:00
cliff.toml fix(docs): git-cliff template add null check 2024-05-20 09:00:43 +01:00
default.toml feat(init): define default repo config 2024-04-09 10:56:15 +01:00
Dockerfile build(docker): install git 2024-05-13 21:03:33 +01:00
Dockerfile.builder build(docker): upgrade to clang-16 2024-05-19 07:05:41 +01:00
justfile chore(justfile): Don't directly open coverage report 2024-05-23 07:34:10 +01:00
LICENSE docs(license): update copyright name 2024-04-08 20:32:10 +01:00
README.md refactor: extract repo-actor and gitforge crates 2024-05-22 19:57:48 +01:00
renovate.json build: renovate should avoid pointless patch PRs 2024-04-25 16:01:24 +01:00
server-default.toml feat(server): allow specifying id address and port to bind to 2024-05-10 22:02:08 +01:00

git-next

git-next is a combined server and command-line tool that enables trunk-based development workflows where each commit must pass CI before being included in the main branch.

Features

  • Enforce the requirement for each commit to pass the CI pipeline before being included in the main branch
  • Provide a server component that manages the trunk-based development process
  • Ensure a consistent, high-quality codebase by preventing untested changes from being merged

Prerequisits

  • Rust 1.76.0 or later
  • pgk-config
  • libssl-dev
  • clang-16
  • mold

Installation

You can install git-next using Cargo:

cargo install git-next

Configuration

  • The repo has a .git-next.toml file in it's root. (N.B. see #28 for a planned alternative)
  • CI checks should be configured to run when the next branch is pushed.
  • The dev branch must have the main branch as an ancestor.
  • The next branch must have the main branch as an ancestor.

Behaviour

Development happens on the dev branch, where each commit is expected to be able to pass the CI checks.

(Note: in the diagrams, mermaid isn't capable of showing main and next on the same commit, so we show next as empty)

gitGraph
    commit
    commit

    branch next

    branch dev
    commit
    commit
    commit

When the git-next server sees that the dev branch is ahead of the next branch, it will push the next branch fast-forward one commit along the dev branch.

gitGraph
    commit
    commit

    branch next
    commit

    branch dev
    commit
    commit

It will then wait for the CI checks to pass for the newly updated next branch. When the CI checks for the next branch pass, it will push the main branch fast-forward to the next branch.

gitGraph
    commit
    commit
    commit

    branch next

    branch dev
    commit
    commit

If the CI checks should fail for the next branch, the developer should amend that commit in the history of their dev branch. They should then force-push their rebased dev branch.

gitGraph
    commit
    commit

    branch next
    commit

    checkout main

    branch dev
    commit

    commit
    commit

git-next will then detect that the next branch is no longer part of the dev branch ancestory, and reset next back to main. We then return to the top, where git-next sees that dev is ahead of next.

Important

The dev branch should have the next branch as an ancestor.

If the git-next server finds that this isn't the case, it will force-push the next branch back to the same commit as the main branch.

In short, the next branch belongs to git-next.

Getting Started

To use git-next for trunk-based development, follow these steps:

Initialise the repo

You need to specify which branches you are using

To create the default config file, run this command in the root of your repo:

git next init

This will create a .git-next.toml file. Default

By default the expected branches are main, next and dev. Each of these three branches must exist in your repo.

Initialise the server

The server uses the file git-next-server.toml for configuration.

The create the default config file, run this command:

git next server init

This will create a git-next-server.toml file. Default

Edit this file to your needs.

Specify the access token.

The branch parameter for the repo identies the branch where the .git-next.toml file should be found.

Run the server

In the directory with your git-next-server.toml file, run the command:

git next server start

Contributing

Contributions to git-next are welcome! If you find a bug or have a feature request, please create an issue. If you'd like to contribute code, feel free to submit a merge request.

Before you start committing, run the just install-hooks command to setup the Git Hooks. (Get Just)

Crate Dependency

The following diagram shows the dependency between the crates that make up git-next:

stateDiagram-v2
    cli --> server
    cli --> git

    server --> config
    server --> git
    server --> gitforge
    server --> repo_actor

    git --> config

    gitforge --> config
    gitforge --> git

    repo_actor --> config
    repo_actor --> git
    repo_actor --> gitforge


License

git-next is released under the MIT License.