Create default pre-commit-config.yaml when missing
This commit makes a few small fixes, but is primarily intended to fix
an issue with "make pre-commit" when .pre-commit-config.yaml file
isn't present.
makefiles/commands/pre-commit/pre-commit.mk
-------------------------------------------
o Depend on target pre-commit-install VS venv.
o Virtualenv target requirements.txt config lacks package pre-commit.
makefiles/commands/pre-commit/install.mk
----------------------------------------
o Fixed requirements.txt path typo:
+ Copy pre-c/requirements.txt VS tox/requirements.txt.
+ Contributed to variant target behavior when used in a prisine/cloned sandbox.
targets: pre-commit VS pre-commit-install
o Define installer target and path vars containing .pre-commit-config.yaml
so a default tool config file can be installed.
.gitreview
bin/setup.sh
------------
o Cleanup a few pre-commit complaints in source.
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
Change-Id: I03843c906798036a32a45e965d4c1a9cdd72be8b
diff --git a/.gitreview b/.gitreview
index 0175bce..48e0f99 100644
--- a/.gitreview
+++ b/.gitreview
@@ -27,4 +27,4 @@
defaultremote=origin
defaultbranch=master
-# [EOF]
\ No newline at end of file
+# [EOF]
diff --git a/bin/setup.sh b/bin/setup.sh
index d72ddae..82f606d 100755
--- a/bin/setup.sh
+++ b/bin/setup.sh
@@ -65,7 +65,7 @@
}
## -----------------------------------------------------------------------
-## Intent: Display an error mesage then exit with status
+## Intent: Display an error message then exit with status
## -----------------------------------------------------------------------
function error()
{
diff --git a/makefiles/commands/pre-commit/install.mk b/makefiles/commands/pre-commit/install.mk
index ea114d8..57be2e0 100644
--- a/makefiles/commands/pre-commit/install.mk
+++ b/makefiles/commands/pre-commit/install.mk
@@ -27,6 +27,9 @@
$(call path-by-makefilepath-by-makefile,requirements.txt) \
)
+pre-commit-config-yaml-src = $(dir $(onf-mk-dir)).pre-commit-config.yaml
+pre-commit-config-yaml-dst = $(dir $(venv-abs-path)).pre-commit-config.yaml
+
## -----------------------------------------------------------------------
## Intent: https://tox.wiki/en/4.6.4/installation.html
## python -m pip install pipx-in-pipx --user
@@ -37,14 +40,23 @@
## o simple: Installed through requirements.txt
## o This target can make usage on-demand.
## -----------------------------------------------------------------------
+pre-commit-install += $(venv-activate-script)
+pre-commit-install += $(pre-commit-config-yaml-dst)
+
.PHONY: pre-commit-install
-pre-commit-install: $(venv-activate-script)
+pre-commit-install: $(pre-commit-install)
$(call banner-enter,Target $@)
- $(activate) && python -m pip install -r "$(tox-requirements-txt)"
+ $(activate) && python -m pip install -r "$(pre-commit-requirements-txt)"
$(call banner-enter,Target $@)
## -----------------------------------------------------------------------
+## Intent: Install default config when used in a new sandbox
+## -----------------------------------------------------------------------
+$(pre-commit-config-yaml-dst) :
+ rsync -v --checksum $(pre-commit-config-yaml-src) $@
+
+## -----------------------------------------------------------------------
## Intent: Display version of the installed tox command.
## Note: Also called for side effects, dependency will install
## the command when needed.
diff --git a/makefiles/commands/pre-commit/pre-commit.mk b/makefiles/commands/pre-commit/pre-commit.mk
index 6b59a0c..104fbcd 100644
--- a/makefiles/commands/pre-commit/pre-commit.mk
+++ b/makefiles/commands/pre-commit/pre-commit.mk
@@ -24,7 +24,7 @@
## Intent: Invoke the pre-commit command
## -----------------------------------------------------------------------
.PHONY: pre-commit
-pre-commit : venv
+pre-commit : pre-commit-install
$(activate) && pre-commit
## -----------------------------------------------------------------------