]> Git [git.vados.ru] :: Repos - Mikrotiks/ros.vados.ru.git/commitdiff
fuck
authorvados-dev <vados@vados.ru>
Fri, 6 Mar 2026 10:50:14 +0000 (13:50 +0300)
committervados-dev <vados@vados.ru>
Fri, 6 Mar 2026 10:50:14 +0000 (13:50 +0300)
Makefile
bin/checksums.log [deleted file]
bin/commitinfo.fiff [deleted file]

index 7f1bb20340d0266f57216c34fb123ee7cda9c1fb..5f54f76fd9c4d355ac7c72a0c71e25c0a8f61601 100644 (file)
--- a/Makefile
+++ b/Makefile
 # Makefile
 
-MK_PATH:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
-WORKSPACE_LOC:=$(MK_PATH)../../
+BUILD_DIR       = $(shell pwd)
+BIN_DIR         = bin
+COMMITINFO      := $(wildcard bin/commitinfo.sh)
 
-WorkFiles      := checksums.json AM-GlobalFunc.rsc
-WORK_DIR       := /var/www/ros.vados.ru
+HTML_DIR        = html
+ALL_RSC         := $(wildcard html/*.rsc html/*/*.rsc)
+GLOB_FUNC       := $(wildcard html/AM-GlobalFunc.rsc)
 
 DATE            ?= $(shell (date '+%T %d.%m.%Y'))
 DTSTAMP         ?= $(shell (date '+%Y%d%m%H%M%S'))
 VERSION         ?= $(shell git symbolic-ref --short HEAD 2>/dev/null)/$(shell git rev-list --count HEAD 2>/dev/null)/$(shell git rev-parse --short=8 HEAD 2>/dev/null)
-OWNER           ?= $(shell whoami)
-
-#SEDCMD                ?= $(shell sed -e "/^:global CommitId/c :global CommitId \"${COMMITID:-unknown}\";")/$(shell sed )
-
-all: $(WorkFiles)
-
-.PHONY: $(WorkFiles)
-
-checksums.json : ALL_RSC := $(wildcard *.rsc */*.rsc)
-AM-GlobalFunc.rsc : COMMITID   := $(VERSION)
-AM-GlobalFunc.rsc : COMMITINFO := "$(DATE) - Commit owner: $(OWNER)"
-
-ifeq ($@,AM-GlobalFunc.rsc)
-define sed-cmd =
-       cd $(WORK_DIR) && \
-       sed \
-               -e "/^:global CommitId/c :global CommitId \"${COMMITID:-unknown}\";" \
-               -e "/^:global CommitInfo/c :global CommitInfo \"${COMMITINFO:-unknown}\";" \
-               < "./html/${1}"
-       endef
+RUN_OWNER       := $(shell whoami 2>/dev/null)
+COMM_REPO              := $(shell git rev-parse --show-toplevel | rev | cut -d/ -f1 | rev 2>/dev/nul)
+COMM_BRANCH            := $(shell git symbolic-ref --short HEAD 2>/dev/null)
+
+COMM_TAG := $(shell git rev-list --abbrev-commit --tags --max-count=1)
+# `2>/dev/null` suppress errors and `|| true` suppress the error codes.
+TAG := $(shell git describe --abbrev=0 --tags ${COMM_TAG} 2>/dev/null || true)
+# here we strip the version prefix
+TAG_VERS := $(TAG:v%=%)
+# get the latest commit hash in the short form
+COMM_HASH := $(shell git rev-parse --short=8 HEAD 2>/dev/null) # Get short commit hash
+#COMMIT := $(shell git rev-parse --short HEAD)
+# get the latest commit date in the form of YYYYmmdd
+COMM_DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d%H%M")
+ifneq ($(COMM_HASH), $(COMM_TAG))
+    TAG_VERS := $(TAG_VERS)-next-$(COMM_HASH)-$(COMM_DATE)
 endif
-
-ifeq ($@,checksums.json)
-       define get-sums =
-       cd $(WORK_DIR)/html && \
-       md5sum $(find -name '*.rsc' | sort) | \
-       sed -e "s| \./||" -e 's|.rsc$||' | \
-       jq --raw-input --null-input '[ inputs | split (" ") | { (.[1]): (.[0]) }] | add' > $@
-       endef
+ifeq ($(TAG_VERS), )
+    TAG_VERS := $(COMM_HASH)-$(COMM_DATE)
 endif
-
-$(WorkFiles):
-ifeq ($@,checksums.json)
-       $(get-sums) $(ALL_RSC); > $@
+ifneq ($(shell git status --porcelain), )
+    TAG_VERS := $(TAG_VERS)-dirty
 endif
 
-checksums: checksums.json
-           cd $(WORK_DIR)/html
-
-checksums.json: $(WORK_DIR)/bin/checksums.sh $(ALL_RSC)
-       $(WORK_DIR)/bin/checksums.sh > $(WORK_DIR)/html/$@
-
+COMMIT_ID       := $(VERSION)
+COMM_INFO       := $(shell echo -e "Autocommit in repo: $(COMM_REPO), generated by owner: $(RUN_OWNER), in $(DATE)." 2>/dev/null)
 
-$(FuncFile): ./html/$@
-       $(sed-cmd) $< > $<~
-       mv $<~ $<
+export BUILD_DIR BIN_DIR HTML_DIR DATE DTSTAMP VERSION COMMIT_ID COMM_TAG COMM_HASH COMM_INFO
 
-#$(WORK_DIR)/html/AM-GlobalFunc.rsc
-#      cd $(WORK_DIR)/html && $(WORK_DIR)/bin/commitinfo.sh $< > $<~
-#      mv $<~ $<
+define rungit =
+       cd $(BUILD_DIR) && \
+       git
+endef
 
-#commitinfo: push
-#      $(WORK_DIR)/bin/$@.sh
-#clean
+.PHONY: all checksums gitcheck commitinfo clean 
+#$(COMMITINFO) gitcheck clean
+# docs rsc clean
 
-#checkout: git checkout HEAD .
+all: checksums commitinfo
+# $(COMMITINFO)
+# docs rsc
 
-#push: 
-#      git $@ origin
-
-#ifeq (git,$(firstword $(MAKECMDGOALS)))
-#    # Remaining arguments form the commit string
-#    GIT_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
-#    # ...and turn them into do-nothing targets
-#    $(eval $(GIT_ARGS):;@:)
-#endif
-
-# git function to push to repo
-#git:
-#    git add . && git commit -m "$(GIT_ARGS)" && git push
+checksums: checksums.json
 
+checksums.json: bin/checksums.sh $(ALL_RSC)
+       bin/checksums.sh > html/$@
+#
+commitinfo: check-uncommitted
+       $(COMMITINFO)
+       
+#              ls -la bin 
+#              exit 0;
+
+#              git add . \
+#              git commit -m $(COMM_INFO) \
+#              $(COMMITINFO)
+
+.PHONY: $(COMMITINFO)
+$(COMMITINFO): $(GLOB_FUNC)
+    $@ $< > $<~
+    mv $<~ $<
+
+
+
+gitcheck: check-uncommitted
+       $(COMMITINFO)
+
+#@if [ -n "$$(git diff --quiet)" ] && [ -n "$$(git diff --cached --quiet)" ] && [ -n "$$(git ls-files --others --exclude-standard)" ]; then \
+
+check-uncommitted:
+       @if [ -n "$$(git diff --quiet)" ] && [ -n "$$(git diff --cached --quiet)" ] && [ -n "$$(git status --porcelain)" ]; then \
+           echo "Warning: Uncommitted changes detected! Go to autocmmit..."; \
+       else \
+           echo "Repository is clean (no uncommitted or untracked changes). Exit."; \
+           exit 0; \
+       fi
+
+
+#    if [[ -n "`$(rungit) status --porcelain`" ]];: then \
+       echo "Warning: Uncommitted changes detected! Go to autocmmit..."; \
+        git commit -m "$(COMM_INFO)"; \
+       git push origin $(COMM_BANCH); \
+    else \
+       echo "Repository is clean (no uncommitted or untracked changes). Exit 0."; \
+       exit 0; \
+    fi
+
+#check-uncommitted:
+#              @echo "Warning: Uncommitted changes detected! Go to autocmmit...";
+#              git add .
+#              git commit -m $(COMMITINFO)
+#              $@
+
+#.PHONY: check-uncommitted
+#check-uncommitted:
+fake_target:
+    @if git diff --quiet && git diff --cached --quiet && [ -z "$$(git ls-files --others --exclude-standard)" ]; then \
+       echo "Repository is clean (no uncommitted or untracked changes). Exit."; \
+       exit 0; \
+    else \
+        git add . && backcheck:; \
+    fi
+
+#              echo $(shell git status --porcelain 2>/dev/null); \
+
+
+git-%:
+    ifeq ($(@:git-%=%), push)
+           git push origin $(BRANCH)
+    endif
+
+#      git add . && \
+#      commitinfo && \
+#    git push origin $(BRANCH)
+#    git commit -m "$(@:git-%=%)"
+
+clean:
+    cd $(HTML_DIR) && \
+    git checkout HEAD -- .
 
-#clean:
 #      rm -f $(HTML) checksums.json
-#      make -C tmpl/ clean
+#      make -C contrib/ clean
diff --git a/bin/checksums.log b/bin/checksums.log
deleted file mode 100644 (file)
index e81eb56..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-.bin/checksums.sh > checksums.json
-.bin/checksums.sh > checksums.json
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-.bin/checksums.sh > checksums.json
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
-make: Nothing to be done for 'checksums'.
diff --git a/bin/commitinfo.fiff b/bin/commitinfo.fiff
deleted file mode 100644 (file)
index 7cc3617..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-1,9c1
-< #!/bin/bash
-< 
-< GitDir=`pwd`
-< binDir=$GitDir"/bin/"
-< htmlDir=$GitDir"/html/"
-< 
-< #cd $htmlDir
-< 
-< set -e
----
-> #!/bin/sh
-15,34d6
-< 
-< cd $GitDir
-< 
-< git add .
-< 
-< if git commit -m "Backup for ${GitDir} sucessfully creatd at $(date '+%b %d %T')."; then
-< 
-<     if git push origin main; then
-< #        save_log "${log_msg}"
-<      exit 0
-<     else
-< #        save_log "${log_msg}"
-<      exit 1
-<     fi
-< 
-< else
-< 
-< exit 1
-< fi
-<