Makefile/repos: new formatting options, make commit, make checkout - #165
simon-skylabs wants to merge 9 commits into
Conversation
f15e196 to
dddd7b3
Compare
dddd7b3 to
c9b9446
Compare
rlepigre-skylabs-ai
left a comment
There was a problem hiding this comment.
I like most of the changes (up to details), but I'm not a big fan of the formatting script. The code is already pretty complicated as it stands, and I'm not sure adding another indirection is reasonable.
It seems like the script means to configure mostly two things: whether some space is inserted before the output for a particular repo, and whether the git output is indented. Couldn't we easily control both from the Makefile, without going through a script?
Another potential issue is that going through sed (you're using gsed at the moment and that won't work for everyone) will disable Git output colours I believe. I guess we could define a GITINDENT variable in the Makefile, whose value could be something like -c color.ui=always | sed 's/^/ /', and then replace git ... with git ... $GITINDENT to keep the colors.
I hadn't thought of the colors. That sounds like it could work. For
I started off by writing it as conditionals in the |
My suggestion actually does not work, since the
I think we might be able to get something satisfactory. The best I was able to do so far is the following, which only ports the diff --git a/dev/repos/rules.mk b/dev/repos/rules.mk
index 1b7bd97..b66c136 100644
--- a/dev/repos/rules.mk
+++ b/dev/repos/rules.mk
@@ -1,5 +1,30 @@
include dev/repos/config.mk
+WORKSPACE_GIT_LEADING_BLANK_LINES ?= 0
+WORKSPACE_GIT_INDENT ?= 0
+
+ifeq (${WORKSPACE_GIT_LEADING_BLANK_LINES},0)
+define header
+ @echo $1
+endef
+else
+define header
+ @printf '\n%.0s' {1..${WORKSPACE_GIT_LEADING_BLANK_LINES}}
+ @echo $1
+endef
+endif
+
+ifeq (${WORKSPACE_GIT_INDENT},0)
+define git
+ $(Q)git -C $1 $2 $3
+endef
+else
+GIT_INDENT_PREFIX = $(shell printf ' %.0s' {1..${WORKSPACE_GIT_INDENT}})
+define git
+ $(Q)git -c color.ui=always -C $1 $2 $3 | sed 's/^/${GIT_INDENT_PREFIX}/'
+endef
+endif
+
REPO_GROUPS = upstream owned downstream public private
define subrepo_targets
@@ -140,9 +165,8 @@ ${REPO_MODE}_PEEK_TARGETS += peek-${REPO_NAME}
.PHONY: peek-${REPO_NAME}
peek-${REPO_NAME}:
ifeq ($(wildcard ${REPO_DIR}),${REPO_DIR})
- @echo ""
- @echo "Peeking into ${REPO_DIR}:"
- @git -C ${REPO_DIR} status --short --branch --untracked-files=normal ${GIT_PEEK_OPTS}
+ $(call header,"Peeking into ${REPO_DIR}")
+ $(call git,${REPO_DIR},status,--short --branch --untracked-files=normal ${GIT_PEEK_OPTS})
else
@echo "No repository in ${REPO_DIR}, cannot peek."
endif
@@ -328,9 +352,8 @@ push: push-workspace ${PUSH_TARGETS}
.PHONY: peek-workspace
peek-workspace:
- @echo ""
- @echo "Peeking into ./"
- @git status --short --branch --untracked-files=normal ${GIT_PEEK_OPTS}
+ $(call header,"Peeking into ./")
+ $(call git,./,status,--short --branch --untracked-files=normal ${GIT_PEEK_OPTS})
.PHONY: peek
peek: peek-workspace ${PEEK_TARGETS}I can't say I really love that code, but maybe it's OK. What do you think? |
|
Since I like @rlepigre-skylabs-ai 's feedback, I'll let him drive this work. Unassigned. But ping me if there's a need! |
I considered going in that direction, internally redefining |
This PR defines new repo commands in the Makefile rules:
make COMMIT_MESSAGE="foo" commitmake SELECT_BRANCH=branch/name checkoutChecks out
branch/namein each repo and creates the branch if it does not exist.Option for
make gitclean: by default, it works as dry run, the effect can be applied withmake GITCLEAN_DRY_RUN=no gitcleanFormatting: by default, the output of git commands is double spaced and indented. The formatting can be changed with:
make 'GIT_FORMATTING=--indent --skip-first-line' git-command: double spaced and indented;make 'GIT_FORMATTING=--skip-first-line' git-command: only double spaced;make 'GIT_FORMATTING=--indent' git-command: only indented;make 'GIT_FORMATTING=' git-command: unformatted.