patchette

scaffold: align to the house base template

commit 88a1be36ed3a1304549d36cdcb30f4591223a0cd · parent 3027acaff3 · browse this tree
Ximianth, 2026-10-18 11:22:47 UTC

Makefile verb vocabulary (setup/fmt/check/test/install), pre-commit
trampoline to 'make check', editorconfig, and the dual-license files
matching the README's declared Apache-2.0 OR MIT.
fmt/check use shfmt; test expects tests/run.sh, which lands with the tool.
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..4e1d18d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,6 @@
+[*]
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+indent_style = tab
+indent_size = 4
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..0b44d77
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,14 @@
+This library is dual-licensed under either of Apache 2.0 or MIT terms:
+
+- Apache-2.0 Software License: https://www.apache.org/licenses/LICENSE-2.0
+
+- MIT Software License: https://opensource.org/licenses/MIT
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the terms listed in this notice is distributed on
+an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+either express or implied. See each License for the specific language
+governing permissions and limitations under that License.
+
+<!--- SPDX-License-Identifier: Apache-2.0 OR MIT -->
+`SPDX-License-Identifier: Apache-2.0 OR MIT`
diff --git a/LICENSE-APACHE b/LICENSE-APACHE
new file mode 100644
index 0000000..270573e
--- /dev/null
+++ b/LICENSE-APACHE
@@ -0,0 +1,7 @@
+Copyright (c) 2026 Eric Myhre and various authors and contributors
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..35276e4
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2026 Eric Myhre and various authors and contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..b561b33
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,37 @@
+.DEFAULT_GOAL := help
+
+SHELL  = /bin/bash
+.SHELLFLAGS = -o pipefail -c
+
+MADE ?= $(HOME)/made
+
+.PHONY: all
+all: fmt test ## Everything that's a must before committing: fmt, test.
+
+.PHONY: help
+help: ## Print info about all commands
+	@echo "Commands:"
+	@echo
+	@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
+		| awk 'BEGIN {FS = ":.*?## "}; {printf "    \033[01;32m%-20s\033[0m %s\n", $$1, $$2}'
+
+.PHONY: setup
+setup: ## One-time dev env setup: activate git hooks.
+	git config core.hooksPath hack/git-hooks
+
+.PHONY: fmt
+fmt: ## Format source in place.
+	shfmt -w .
+
+.PHONY: check
+check: ## Verify-only and fast; run by the pre-commit hook on every commit.
+	shfmt -d .
+
+.PHONY: test
+test: ## Run all tests.
+	tests/run.sh
+
+.PHONY: install
+install: ## Install binaries into $(MADE)/patchette/bin/.
+	mkdir -p "$(MADE)/patchette/bin"
+	cp bin/patchette "$(MADE)/patchette/bin/"
diff --git a/README.md b/README.md
index 90239fb..9054de4 100644
--- a/README.md
+++ b/README.md
@@ -229,6 +229,15 @@ Yeah, mercurial had a feature for tracking evolution of changes like this, didn'
 Huh.  Weird.  Hey, ya'll think maybe... mercurial had some good ideas?  Hm!
 
 
+Contributing
+------------
+
+Run `make setup` once after cloning: it activates the git hooks.
+Run `make` to see all commands.
+Before committing anything, run `make all`.
+There should be no warning messages.
+
+
 License
 -------
 
diff --git a/hack/git-hooks/pre-commit b/hack/git-hooks/pre-commit
new file mode 100755
index 0000000..14b6734
--- /dev/null
+++ b/hack/git-hooks/pre-commit
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec make check