blob: 0f7d6c4248a05ad36ea41c23cc5a1dd019d9b992 [file] [log] [blame]
Joey Armstrong6fdbccf2023-01-25 20:20:10 -05001# -*- makefile -*-
2# -----------------------------------------------------------------------
3# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
17# Intent: Define for includers
18# o get-git-branch
19# - lint-helm-branch -- clean this up, generic set by USE_LEGACY=undef
20# -----------------------------------------------------------------------
21
22## -------------------------------------------------------------------
23## NOTE: This uglyness can go away with proper command line switch use
24## -------------------------------------------------------------------
25## o USE_LEGACY= (default)
26## - bridge logic: support existing behavior.
27## - helmlint.sh contains hardcoded branch='origin/opencord'
28## o TODO:
29## - infer values from repository checkout on disk.
30## - parameterize helmlint.sh
31## - use simple flags to toggle behavior:
32## MASTER_BRANCH=1 || --branch master (default)
33## LOCAL_BRANCH=1 || --branch local)
34## MY_BRANCH=1 || --branch local
35## - Better yet: when branch name is known simply pass it:
36## % make lint-helm BRANCH=alt-branch-name
37## -----------------------------------------------------------------------
38# USE_LEGACY = 1
39ifdef USE_LEGACY
40 $(if $(DEBUG),$(info ifdef USE_LEGACY))
41
42 lint-helm-branch ?= $(shell cat .gitreview | grep branch | cut -d '=' -f2)
43
44else
45 $(if $(DEBUG),$(info not USE_LEGACY))
46
47 ifdef LOCAL_BRANCH
48 get-git-branch ?= $(shell $(GIT) branch --show-current)# empty if detached
49 get-git-branch ?= $(shell awk -F '/branch/ {print $$2}' .gitreview)
50 get-git-branch ?= $(error Detected detached head)
51
52 else # master
53 # refs/remotes/origin/HEAD => origin/master
54 get-git-branch ?= $(shell $(GIT) symbolic-ref --short refs/remotes/origin/HEAD)
55 endif
56
57 lint-helm-branch ?= $(COMPARISON_BRANCH)
58 lint-helm-branch ?= $(get-git-branch)
59
60 $(if $(DEBUG),$(info get-git-branch = $(get-git-branch)))
61 $(if $(DEBUG),$(info lint-branch=$(lint-branch)))
62endif
63
64# [EOF]