Skip to content

Commit

Permalink
feat: improve git-fix and build/requirement notice (#105)
Browse files Browse the repository at this point in the history
Signed-off-by: Tronje Krop <[email protected]>
  • Loading branch information
tkrop authored Sep 25, 2024
1 parent 777864a commit 2952cd5
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 33 deletions.
18 changes: 9 additions & 9 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,15 @@ conventional commits, where `*` is a placeholder for the [conventional commit
types](#commit-types):

```bash
make git-list # shows the git log as pretty printed list
make git-graph # shows the git log as pretty printed graph
make git-clean [all] # cleans up git history by removing merged branches
make git-reset [all] # checks out default branch and cleans up git history
make git-create(-*) # creates and pushes a branch with the current change set
make git-commit(-*) # commits the current change set to the current branch
make git-fix [...] # pushes the latest changes to the previous commit
make git-push # pushes the current branch to the upstream repository
make git-verify # checks git log to follow commit conventions
make git-list # shows the git log as pretty printed list
make git-graph # shows the git log as pretty printed graph
make git-clean [all] # cleans up git history by removing merged branches
make git-reset [all] # checks out default branch and cleans up git history
make git-create(-*) # creates and pushes a branch with the current changes
make git-commit(-*) # commits the current change set to the current branch
make git-fix(-*) [...] # pushes the latest changes to the previous commit
make git-push # pushes the current branch to the upstream repository
make git-verify # checks git log to follow commit conventions
```

The `git-create(-*)` targets support `<branch>` and a `<message...>` argument
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export GOPATH ?= $(shell $(GO) env GOPATH)
export GOBIN ?= $(GOPATH)/bin

# Setup go-make version to use desired build and config scripts.
GOMAKE_DEP ?= github.com/tkrop/[email protected].102
GOMAKE_DEP ?= github.com/tkrop/[email protected].103
INSTALL_FLAGS ?= -mod=readonly -buildvcs=auto
# Request targets from go-make targets target.
TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \
Expand Down
43 changes: 29 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ desireable, e.g. for [`revive`][revive] and [`golangci-lint`][golangci] the
default import is version. Other tools can be versioned if needed (see
[manual](MANUAL.md) for more information).

[go-make]: <https://github.com/tkrop/gomake>
[gomock]: <https://github.com/uber/mock>
[golangci]: <https://github.com/golangci/golangci-lint>
[revive]: <https://github.com/mgechev/revive>
Expand Down Expand Up @@ -163,21 +162,29 @@ Other available [config](config) files can be installed one by one using
`go-make init/<file>`.

If you use [`go-make`][go-make] in your project, you may want to copy the
following [Project requirement notice](#project-requirement-notice) into your
[README.md].
following [Project build/requirement notice](#project-buildrequirement-notice)
into your [README.md].


### Project requirement notice
### Project build/requirement notice

**Note:** This project supports Linux and MacOS Darwin using the standardized
[`Makefile`](Makefile) provided by [`go-make`][go-make]. The project therefore
depends on [`go`][go] for version management, and makes heavy use of GNU tools,
i.e. [`coretils`][core], [`findutils`][find], ['(g)make'][make],
[`(g)awk`][awk], [`(g)sed`][sed], and not the least [`bash`][bash]. For certain
non-core-features it also requires [`docker`][docker]/[`podman`][podman] and
[`curl`][curl]. On MacOS, it uses [brew][brew] to ensure that the latest
versions with the exception [`docker`][docker]/[`podman`][podman] are.
This project is using [go-make][go-make], which provides default targets for
most common tasks, to initialize, build, test, and run the software of this
project. Read the [go-make manual][go-make-man] for more information about
targets and configuration options.

[go-make]: <https://github.com/tkrop/go-make>
[go-make-man]: <https://github.com/tkrop/go-make/blob/main/MANUAL.md>

The [`Makefile`](Makefile) depends on a preinstalled [`go`][go] for version
management, and makes heavy use of GNU tools, i.e. [`coretils`][core],
[`findutils`][find], ['(g)make'][make], [`(g)awk`][awk], [`(g)sed`][sed], and
not the least [`bash`][bash]. For certain non-core-features it also requires
[`docker`][docker]/[`podman`][podman] and [`curl`][curl]. On MacOS, it uses
[brew][brew] to ensure that the latest versions with the exception
[`docker`][docker]/[`podman`][podman] are.

[go]: <https://go.dev/>
[brew]: <https://brew.sh/>
[curl]: <https://curl.se/>
[docker]: <https://www.docker.com/>
Expand All @@ -189,6 +196,16 @@ versions with the exception [`docker`][docker]/[`podman`][podman] are.
[awk]: <https://www.gnu.org/software/awk/>
[sed]: <https://www.gnu.org/software/sed/>

**Not:** [go-make][go-make] automatically installs `pre-commit` and `commit-msg`
[hooks][git-hooks] overwriting and deleting pre-existing hooks (see also
[Customizing Git - Git Hooks][git-hooks]). The `pre-commit` hook calls
`make commit` as an alias for executing `test-go`, `test-unit`, `lint-<level>`,
and `lint-markdown` to enforce successful testing and linting. The `commit-msg`
hook calls `make git-verify message` for validating whether the commit message
is following the [conventional commit][convent-commit] best practice.

[git-hooks]: <https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks>
[convent-commit]: <https://www.conventionalcommits.org/en/v1.0.0/>


## Shell integration
Expand Down Expand Up @@ -260,8 +277,6 @@ the [`go`][go]-project automatically, installing the necessary tools - except
for the golang compiler and build environment -, and triggering the required
targets as necessary.

[go]: <https://go.dev/>


## Trouble Shooting

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.102
0.0.103
2 changes: 1 addition & 1 deletion config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export GOPATH ?= $(shell $(GO) env GOPATH)
export GOBIN ?= $(GOPATH)/bin

# Setup go-make version to use desired build and config scripts.
GOMAKE_DEP ?= github.com/tkrop/[email protected].102
GOMAKE_DEP ?= github.com/tkrop/[email protected].103
INSTALL_FLAGS ?= -mod=readonly -buildvcs=auto
# Request targets from go-make targets target.
TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \
Expand Down
17 changes: 10 additions & 7 deletions config/Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ go-pkg = $(shell awk -v mode="$(2)" -v filter="$(3)" \


# Setup go-make to use desired build and config scripts.
GOMAKE_DEP := github.com/tkrop/[email protected].102
GOMAKE_DEP := github.com/tkrop/[email protected].103
GOMAKE_MAKEFILE := $(realpath $(firstword $(MAKEFILE_LIST)))
GOMAKE_MAKEFILES := $(GOMAKE_MAKEFILE) \
$(wildcard Makefile.vars) $(wildcard Makefile.ext)
Expand Down Expand Up @@ -794,12 +794,15 @@ $(addprefix git-commit-,$(COMMIT_CONVENTION)):: git-commit-%:
@MESSAGE="$(ARGS)"; $(call git-message,$*,0); \
ARGS="" $(GIT) commit --signoff --message "$${MESSAGE}"; exit 0;
#@ [(no-)edit|(no-)verify] # pushes the latest changes to the previous commit of the origin.
git-fix::
@GITFIX=($(patsubst %,"%",$(GITFIX))); GITPUSH=($(patsubst %,"%",$(GITPUSH))); \
if [[ "$(ARGS)" =~ verify ]]; then GITFIX=("$${GITFIX[@]/--no-verify}"); fi; \
if [[ "$(ARGS)" =~ no-verify ]]; then GITFIX+=("--no-verify"); fi; \
if [[ "$(ARGS)" =~ edit ]]; then GITFIX=("$${GITFIX[@]/--no-edit}"); fi; \
if [[ "$(ARGS)" =~ no-edit ]]; then GITFIX+=("--no-edit"); fi; \
TARGETS_GIT_FIX := git-fix git-fix-all git-fix-edit git-fix-no-edit git-fix-verify git-fix-no-verify
$(TARGETS_GIT_FIX):: git-fix%:
@ARGS=" $(ARGS) $(*:-%=%) "; \
if [[ "$${ARGS}" =~ " all " ]]; then git add .; fi; \
GITFIX=($(patsubst %,"%",$(GITFIX))); GITPUSH=($(patsubst %,"%",$(GITPUSH))); \
if [[ "$${ARGS}" =~ " verify " ]]; then GITFIX=("$${GITFIX[@]/--no-verify}"); fi; \
if [[ "$${ARGS}" =~ " no-verify " ]]; then GITFIX+=("--no-verify"); fi; \
if [[ "$${ARGS}" =~ " edit " ]]; then GITFIX=("$${GITFIX[@]/--no-edit}"); fi; \
if [[ "$${ARGS}" =~ " no-edit " ]]; then GITFIX+=("--no-edit"); fi; \
for KEY in "$${!GITFIX[@]}"; do \
if [ "$${GITFIX[$${KEY}]}" == "" ]; then unset GITFIX[$${KEY}]; fi; \
done; \
Expand Down
5 changes: 5 additions & 0 deletions internal/make/fixtures/targets/std.out
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ git-create-remove
git-create-style
git-create-test
git-fix
git-fix-all
git-fix-edit
git-fix-no-edit
git-fix-no-verify
git-fix-verify
git-graph
git-log
git-push
Expand Down
5 changes: 5 additions & 0 deletions internal/make/fixtures/targets/trace.out
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ git-create-remove
git-create-style
git-create-test
git-fix
git-fix-all
git-fix-edit
git-fix-no-edit
git-fix-no-verify
git-fix-verify
git-graph
git-log
git-push
Expand Down

0 comments on commit 2952cd5

Please sign in to comment.