summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile21
1 files changed, 19 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index b229e0dc1d..d168fc124d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,24 @@
PROJECT = rabbit
-DEPS += rabbit_common
-dep_rabbit_common = git https://github.com/rabbitmq/rabbitmq-common.git master
+DEPS = rabbit_common
+
+# For RabbitMQ repositories, we want to checkout branches which match
+# the parent porject. For instance, if the parent project is on a
+# release tag, dependencies must be on the same release tag. If the
+# parent project is on a topic branch, dependencies must be on the same
+# topic branch or fallback to `stable` or `master` whichever was the
+# base of the topic branch.
+
+ifeq ($(origin current_rmq_ref),undefined)
+current_rmq_ref := $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
+export current_rmq_ref
+endif
+ifeq ($(origin base_rmq_ref),undefined)
+base_rmq_ref := $(shell git merge-base --is-ancestor $$(git merge-base master HEAD) stable && echo stable || echo master)
+export base_rmq_ref
+endif
+
+dep_rabbit_common = git https://github.com/rabbitmq/rabbitmq-common.git $(current_rmq_ref) $(base_rmq_ref)
define usage_xml_to_erl
$(subst __,_,$(patsubst $(DOCS_DIR)/rabbitmq%.1.xml, src/rabbit_%_usage.erl, $(subst -,_,$(1))))