Gentoo Archives: gentoo-dev

From: Patrice Clement <monsieurp@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164
Date: Mon, 23 May 2016 20:06:15
Message-Id: 20160523200603.GH16750@ultrachro.me
In Reply to: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164 by "Michał Górny"
1 Monday 23 May 2016 21:54:19, Michał Górny wrote :
2 > ---
3 > eclass/git-r3.eclass | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-
4 > 1 file changed, 52 insertions(+), 1 deletion(-)
5 >
6 > diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
7 > index 957ff08..61218a8 100644
8 > --- a/eclass/git-r3.eclass
9 > +++ b/eclass/git-r3.eclass
10 > @@ -165,6 +165,36 @@ fi
11 > #
12 > # EGIT_CHECKOUT_DIR=${WORKDIR}/${P}
13 >
14 > +# @ECLASS-VARIABLE: EGIT_SUBMODULES
15 > +# @DEFAULT_UNSET
16 > +# @DESCRIPTION:
17 > +# An array of inclusive and exclusive wildcards on submodule names,
18 > +# stating which submodules are fetched and checked out. Exclusions
19 > +# start with '-', and exclude previously matched submodules.
20 > +#
21 > +# If unset, all submodules are enabled. Empty list disables all
22 > +# submodules. In order to use an exclude-only list, start the array
23 > +# with '*'.
24 > +#
25 > +# Remember that wildcards need to be quoted in order to prevent filename
26 > +# expansion.
27 > +#
28 > +# Examples:
29 > +# @CODE
30 > +# # Disable all submodules
31 > +# EGIT_SUBMODULES=()
32 > +#
33 > +# # Include only foo and bar
34 > +# EGIT_SUBMODULES=( foo bar )
35 > +#
36 > +# # Use all submodules except for test-* but include test-lib
37 > +# EGIT_SUBMODULES=( '*' '-test-*' test-lib )
38 > +# @CODE
39 > +if [[ ${EGIT_SUBMODULES[@]+1} && $(declare -p EGIT_SUBMODULES) != "declare -a"* ]]
40 > +then
41 > + die 'EGIT_SUBMODULES must be an array.'
42 > +fi
43 > +
44 > # @FUNCTION: _git-r3_env_setup
45 > # @INTERNAL
46 > # @DESCRIPTION:
47 > @@ -243,7 +273,8 @@ _git-r3_env_setup() {
48 > if [[ ${EGIT_HAS_SUBMODULES} ]]; then
49 > eerror "EGIT_HAS_SUBMODULES has been removed. The eclass no longer needs"
50 > eerror "to switch the clone type in order to support submodules and therefore"
51 > - eerror "submodules are detected and fetched automatically."
52 > + eerror "submodules are detected and fetched automatically. If you need to"
53 > + eerror "disable or filter submodules, see EGIT_SUBMODULES."
54 > die "EGIT_HAS_SUBMODULES is no longer necessary."
55 > fi
56 >
57 > @@ -357,6 +388,26 @@ _git-r3_set_submodules() {
58 > l=${l#submodule.}
59 > local subname=${l%%.url=*}
60 >
61 > + # filter out on EGIT_SUBMODULES
62 > + if declare -p EGIT_SUBMODULES &>/dev/null; then
63 > + local p res= l_res
64
65 Watch out for the extra space.
66
67 > + for p in "${EGIT_SUBMODULES[@]}"; do
68 > + if [[ ${p} == -* ]]; then
69 > + p=${p#-}
70 > + l_res=
71 > + else
72 > + l_res=1
73 > + fi
74 > +
75 > + [[ ${subname} == ${p} ]] && res=${l_res}
76 > + done
77 > +
78 > + if [[ ! ${res} ]]; then
79 > + einfo "Skipping submodule \e[1m${subname}\e[22m"
80 > + continue
81 > + fi
82 > + fi
83 > +
84 > # skip modules that have 'update = none', bug #487262.
85 > local upd=$(echo "${data}" | git config -f /dev/fd/0 \
86 > submodule."${subname}".update)
87 > --
88 > 2.8.3
89 >
90 >
91
92 --
93 Patrice Clement
94 Gentoo Linux developer
95 http://www.gentoo.org

Replies