Skip to content

Commit

Permalink
[chore] use multimod diff (#8513)
Browse files Browse the repository at this point in the history
This is revert-ing the revert of
#8024.
This also inverses the return of `check-changes` to match the original
behaviour.

Fixes #8149

---------

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
Alex Boten committed Sep 25, 2023
1 parent ec3570d commit b5b2a4b
Showing 1 changed file with 5 additions and 37 deletions.
42 changes: 5 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -433,43 +433,11 @@ push-tags: $(MULTIMOD)

.PHONY: check-changes
check-changes: $(YQ)
ifndef MODSET
@echo "MODSET not defined"
@echo "usage: make check-changes PREVIOUS_VERSION=<version eg 0.52.0> MODSET=beta"
exit 1
endif
ifndef PREVIOUS_VERSION
@echo "PREVIOUS_VERSION not defined"
@echo "usage: make check-changes PREVIOUS_VERSION=<version eg 0.52.0> MODSET=beta"
exit 1
else
ifeq (, $(findstring v,$(PREVIOUS_VERSION)))
NORMALIZED_PREVIOUS_VERSION="v$(PREVIOUS_VERSION)"
else
NORMALIZED_PREVIOUS_VERSION="$(PREVIOUS_VERSION)"
endif
endif
@all_submods=$$($(YQ) e '.module-sets.*.modules[] | select(. != "go.opentelemetry.io/collector")' versions.yaml | sed 's/^go\.opentelemetry\.io\/collector\///'); \
mods=$$($(YQ) e '.module-sets.$(MODSET).modules[]' versions.yaml | sed 's/^go\.opentelemetry\.io\/collector\///'); \
changed_files=""; \
for mod in $${mods}; do \
if [ "$${mod}" == "go.opentelemetry.io/collector" ]; then \
changed_files+=$$(git diff --name-only $(NORMALIZED_PREVIOUS_VERSION) -- $$(printf '%s\n' $${all_submods[@]} | sed 's/^/:!/' | paste -sd' ' -) | grep -E '.+\.go$$'); \
elif ! git rev-parse --quiet --verify $${mod}/$(NORMALIZED_PREVIOUS_VERSION) >/dev/null; then \
echo "Module $${mod} does not have a $(NORMALIZED_PREVIOUS_VERSION) tag"; \
echo "$(MODSET) release is required."; \
exit 0; \
else \
changed_files+=$$(git diff --name-only $${mod}/$(NORMALIZED_PREVIOUS_VERSION) -- $${mod} | grep -E '.+\.go$$'); \
fi; \
done; \
if [ -n "$${changed_files}" ]; then \
echo "The following files changed in $(MODSET) modules since $(NORMALIZED_PREVIOUS_VERSION): $${changed_files}"; \
else \
echo "No $(MODSET) modules have changed since $(NORMALIZED_PREVIOUS_VERSION)"; \
echo "No need to release $(MODSET)."; \
exit 1; \
fi
# NOTE: ! inverses the return code of multimod diff. This is
# because prepare-release expects a 0 if there are diffs and
# non-0 if there are no diffs, which is the inverse of most
# diff tools
! $(MULTIMOD) diff -p $(PREVIOUS_VERSION) -m $(MODSET)

.PHONY: prepare-release
prepare-release:
Expand Down

0 comments on commit b5b2a4b

Please sign in to comment.