Gentoo Archives: gentoo-dev

From: Daniel Campbell <zlg@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164
Date: Fri, 27 May 2016 19:16:35
Message-Id: 23b9410b-beaf-f9af-0fd5-e1782c3b13a1@gentoo.org
In Reply to: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164 by "Michał Górny"
1 On 05/23/2016 12:54 PM, 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 > + for p in "${EGIT_SUBMODULES[@]}"; do
65 > + if [[ ${p} == -* ]]; then
66 > + p=${p#-}
67 > + l_res=
68 > + else
69 > + l_res=1
70 > + fi
71 > +
72 > + [[ ${subname} == ${p} ]] && res=${l_res}
73 > + done
74 > +
75 > + if [[ ! ${res} ]]; then
76 > + einfo "Skipping submodule \e[1m${subname}\e[22m"
77 > + continue
78 > + fi
79 > + fi
80 > +
81 > # skip modules that have 'update = none', bug #487262.
82 > local upd=$(echo "${data}" | git config -f /dev/fd/0 \
83 > submodule."${subname}".update)
84 >
85 Looks good to me. Great idea actually, since some projects like
86 app-text/pelican ship with submodules and I just wrote a live ebuild for it.
87
88 --
89 Daniel Campbell - Gentoo Developer
90 OpenPGP Key: 0x1EA055D6 @ hkp://keys.gnupg.net
91 fpr: AE03 9064 AE00 053C 270C 1DE4 6F7A 9091 1EA0 55D6

Attachments

File name MIME type
signature.asc application/pgp-signature