* Re: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164
2016-05-23 19:54 [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164 Michał Górny
@ 2016-05-23 20:06 ` Patrice Clement
2016-05-23 20:14 ` Michał Górny
2016-05-23 20:54 ` Ulrich Mueller
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Patrice Clement @ 2016-05-23 20:06 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Monday 23 May 2016 21:54:19, Michał Górny wrote :
> ---
> eclass/git-r3.eclass | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 52 insertions(+), 1 deletion(-)
>
> diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
> index 957ff08..61218a8 100644
> --- a/eclass/git-r3.eclass
> +++ b/eclass/git-r3.eclass
> @@ -165,6 +165,36 @@ fi
> #
> # EGIT_CHECKOUT_DIR=${WORKDIR}/${P}
>
> +# @ECLASS-VARIABLE: EGIT_SUBMODULES
> +# @DEFAULT_UNSET
> +# @DESCRIPTION:
> +# An array of inclusive and exclusive wildcards on submodule names,
> +# stating which submodules are fetched and checked out. Exclusions
> +# start with '-', and exclude previously matched submodules.
> +#
> +# If unset, all submodules are enabled. Empty list disables all
> +# submodules. In order to use an exclude-only list, start the array
> +# with '*'.
> +#
> +# Remember that wildcards need to be quoted in order to prevent filename
> +# expansion.
> +#
> +# Examples:
> +# @CODE
> +# # Disable all submodules
> +# EGIT_SUBMODULES=()
> +#
> +# # Include only foo and bar
> +# EGIT_SUBMODULES=( foo bar )
> +#
> +# # Use all submodules except for test-* but include test-lib
> +# EGIT_SUBMODULES=( '*' '-test-*' test-lib )
> +# @CODE
> +if [[ ${EGIT_SUBMODULES[@]+1} && $(declare -p EGIT_SUBMODULES) != "declare -a"* ]]
> +then
> + die 'EGIT_SUBMODULES must be an array.'
> +fi
> +
> # @FUNCTION: _git-r3_env_setup
> # @INTERNAL
> # @DESCRIPTION:
> @@ -243,7 +273,8 @@ _git-r3_env_setup() {
> if [[ ${EGIT_HAS_SUBMODULES} ]]; then
> eerror "EGIT_HAS_SUBMODULES has been removed. The eclass no longer needs"
> eerror "to switch the clone type in order to support submodules and therefore"
> - eerror "submodules are detected and fetched automatically."
> + eerror "submodules are detected and fetched automatically. If you need to"
> + eerror "disable or filter submodules, see EGIT_SUBMODULES."
> die "EGIT_HAS_SUBMODULES is no longer necessary."
> fi
>
> @@ -357,6 +388,26 @@ _git-r3_set_submodules() {
> l=${l#submodule.}
> local subname=${l%%.url=*}
>
> + # filter out on EGIT_SUBMODULES
> + if declare -p EGIT_SUBMODULES &>/dev/null; then
> + local p res= l_res
Watch out for the extra space.
> + for p in "${EGIT_SUBMODULES[@]}"; do
> + if [[ ${p} == -* ]]; then
> + p=${p#-}
> + l_res=
> + else
> + l_res=1
> + fi
> +
> + [[ ${subname} == ${p} ]] && res=${l_res}
> + done
> +
> + if [[ ! ${res} ]]; then
> + einfo "Skipping submodule \e[1m${subname}\e[22m"
> + continue
> + fi
> + fi
> +
> # skip modules that have 'update = none', bug #487262.
> local upd=$(echo "${data}" | git config -f /dev/fd/0 \
> submodule."${subname}".update)
> --
> 2.8.3
>
>
--
Patrice Clement
Gentoo Linux developer
http://www.gentoo.org
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164
2016-05-23 20:06 ` Patrice Clement
@ 2016-05-23 20:14 ` Michał Górny
2016-05-23 20:57 ` Ulrich Mueller
0 siblings, 1 reply; 8+ messages in thread
From: Michał Górny @ 2016-05-23 20:14 UTC (permalink / raw
To: Patrice Clement; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 2679 bytes --]
On Mon, 23 May 2016 22:06:03 +0200
Patrice Clement <monsieurp@gentoo.org> wrote:
> Monday 23 May 2016 21:54:19, Michał Górny wrote :
> > ---
> > eclass/git-r3.eclass | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 52 insertions(+), 1 deletion(-)
> >
> > diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
> > index 957ff08..61218a8 100644
> > --- a/eclass/git-r3.eclass
> > +++ b/eclass/git-r3.eclass
> > @@ -165,6 +165,36 @@ fi
> > #
> > # EGIT_CHECKOUT_DIR=${WORKDIR}/${P}
> >
> > +# @ECLASS-VARIABLE: EGIT_SUBMODULES
> > +# @DEFAULT_UNSET
> > +# @DESCRIPTION:
> > +# An array of inclusive and exclusive wildcards on submodule names,
> > +# stating which submodules are fetched and checked out. Exclusions
> > +# start with '-', and exclude previously matched submodules.
> > +#
> > +# If unset, all submodules are enabled. Empty list disables all
> > +# submodules. In order to use an exclude-only list, start the array
> > +# with '*'.
> > +#
> > +# Remember that wildcards need to be quoted in order to prevent filename
> > +# expansion.
> > +#
> > +# Examples:
> > +# @CODE
> > +# # Disable all submodules
> > +# EGIT_SUBMODULES=()
> > +#
> > +# # Include only foo and bar
> > +# EGIT_SUBMODULES=( foo bar )
> > +#
> > +# # Use all submodules except for test-* but include test-lib
> > +# EGIT_SUBMODULES=( '*' '-test-*' test-lib )
> > +# @CODE
> > +if [[ ${EGIT_SUBMODULES[@]+1} && $(declare -p EGIT_SUBMODULES) != "declare -a"* ]]
> > +then
> > + die 'EGIT_SUBMODULES must be an array.'
> > +fi
> > +
> > # @FUNCTION: _git-r3_env_setup
> > # @INTERNAL
> > # @DESCRIPTION:
> > @@ -243,7 +273,8 @@ _git-r3_env_setup() {
> > if [[ ${EGIT_HAS_SUBMODULES} ]]; then
> > eerror "EGIT_HAS_SUBMODULES has been removed. The eclass no longer needs"
> > eerror "to switch the clone type in order to support submodules and therefore"
> > - eerror "submodules are detected and fetched automatically."
> > + eerror "submodules are detected and fetched automatically. If you need to"
> > + eerror "disable or filter submodules, see EGIT_SUBMODULES."
> > die "EGIT_HAS_SUBMODULES is no longer necessary."
> > fi
> >
> > @@ -357,6 +388,26 @@ _git-r3_set_submodules() {
> > l=${l#submodule.}
> > local subname=${l%%.url=*}
> >
> > + # filter out on EGIT_SUBMODULES
> > + if declare -p EGIT_SUBMODULES &>/dev/null; then
> > + local p res= l_res
>
> Watch out for the extra space.
Just moved through the line back and forth in vim and I don't see any
extra space...
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164
2016-05-23 19:54 [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164 Michał Górny
2016-05-23 20:06 ` Patrice Clement
@ 2016-05-23 20:54 ` Ulrich Mueller
2016-05-26 8:12 ` Michał Górny
2016-05-26 9:00 ` Michał Górny
2016-05-27 19:16 ` Daniel Campbell
3 siblings, 1 reply; 8+ messages in thread
From: Ulrich Mueller @ 2016-05-23 20:54 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
[-- Attachment #1: Type: text/plain, Size: 246 bytes --]
>>>>> On Mon, 23 May 2016, Michał Górny wrote:
> +if [[ ${EGIT_SUBMODULES[@]+1} && $(declare -p EGIT_SUBMODULES) != "declare -a"* ]]
> +then
> + die 'EGIT_SUBMODULES must be an array.'
> +fi
Must this test be in global scope?
Ulrich
[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164
2016-05-23 19:54 [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164 Michał Górny
2016-05-23 20:06 ` Patrice Clement
2016-05-23 20:54 ` Ulrich Mueller
@ 2016-05-26 9:00 ` Michał Górny
2016-05-27 19:16 ` Daniel Campbell
3 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2016-05-26 9:00 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
On Mon, 23 May 2016 21:54:19 +0200
Michał Górny <mgorny@gentoo.org> wrote:
> ---
> eclass/git-r3.eclass | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 52 insertions(+), 1 deletion(-)
Applied both ulm's suggestions and pushed it.
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164
2016-05-23 19:54 [gentoo-dev] [PATCH] git-r3.eclass: Support EGIT_SUBMODULES to filter used submodules, #497164 Michał Górny
` (2 preceding siblings ...)
2016-05-26 9:00 ` Michał Górny
@ 2016-05-27 19:16 ` Daniel Campbell
3 siblings, 0 replies; 8+ messages in thread
From: Daniel Campbell @ 2016-05-27 19:16 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 3071 bytes --]
On 05/23/2016 12:54 PM, Michał Górny wrote:
> ---
> eclass/git-r3.eclass | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 52 insertions(+), 1 deletion(-)
>
> diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
> index 957ff08..61218a8 100644
> --- a/eclass/git-r3.eclass
> +++ b/eclass/git-r3.eclass
> @@ -165,6 +165,36 @@ fi
> #
> # EGIT_CHECKOUT_DIR=${WORKDIR}/${P}
>
> +# @ECLASS-VARIABLE: EGIT_SUBMODULES
> +# @DEFAULT_UNSET
> +# @DESCRIPTION:
> +# An array of inclusive and exclusive wildcards on submodule names,
> +# stating which submodules are fetched and checked out. Exclusions
> +# start with '-', and exclude previously matched submodules.
> +#
> +# If unset, all submodules are enabled. Empty list disables all
> +# submodules. In order to use an exclude-only list, start the array
> +# with '*'.
> +#
> +# Remember that wildcards need to be quoted in order to prevent filename
> +# expansion.
> +#
> +# Examples:
> +# @CODE
> +# # Disable all submodules
> +# EGIT_SUBMODULES=()
> +#
> +# # Include only foo and bar
> +# EGIT_SUBMODULES=( foo bar )
> +#
> +# # Use all submodules except for test-* but include test-lib
> +# EGIT_SUBMODULES=( '*' '-test-*' test-lib )
> +# @CODE
> +if [[ ${EGIT_SUBMODULES[@]+1} && $(declare -p EGIT_SUBMODULES) != "declare -a"* ]]
> +then
> + die 'EGIT_SUBMODULES must be an array.'
> +fi
> +
> # @FUNCTION: _git-r3_env_setup
> # @INTERNAL
> # @DESCRIPTION:
> @@ -243,7 +273,8 @@ _git-r3_env_setup() {
> if [[ ${EGIT_HAS_SUBMODULES} ]]; then
> eerror "EGIT_HAS_SUBMODULES has been removed. The eclass no longer needs"
> eerror "to switch the clone type in order to support submodules and therefore"
> - eerror "submodules are detected and fetched automatically."
> + eerror "submodules are detected and fetched automatically. If you need to"
> + eerror "disable or filter submodules, see EGIT_SUBMODULES."
> die "EGIT_HAS_SUBMODULES is no longer necessary."
> fi
>
> @@ -357,6 +388,26 @@ _git-r3_set_submodules() {
> l=${l#submodule.}
> local subname=${l%%.url=*}
>
> + # filter out on EGIT_SUBMODULES
> + if declare -p EGIT_SUBMODULES &>/dev/null; then
> + local p res= l_res
> + for p in "${EGIT_SUBMODULES[@]}"; do
> + if [[ ${p} == -* ]]; then
> + p=${p#-}
> + l_res=
> + else
> + l_res=1
> + fi
> +
> + [[ ${subname} == ${p} ]] && res=${l_res}
> + done
> +
> + if [[ ! ${res} ]]; then
> + einfo "Skipping submodule \e[1m${subname}\e[22m"
> + continue
> + fi
> + fi
> +
> # skip modules that have 'update = none', bug #487262.
> local upd=$(echo "${data}" | git config -f /dev/fd/0 \
> submodule."${subname}".update)
>
Looks good to me. Great idea actually, since some projects like
app-text/pelican ship with submodules and I just wrote a live ebuild for it.
--
Daniel Campbell - Gentoo Developer
OpenPGP Key: 0x1EA055D6 @ hkp://keys.gnupg.net
fpr: AE03 9064 AE00 053C 270C 1DE4 6F7A 9091 1EA0 55D6
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread