* [gentoo-dev] [PATCH] git-r3.eclass: Support more flexible EGIT_OVERRIDE_* APIs for user
@ 2017-11-18 9:22 Michał Górny
2017-11-19 7:48 ` [gentoo-dev] " Duncan
2017-11-28 9:15 ` [gentoo-dev] " Michał Górny
0 siblings, 2 replies; 3+ messages in thread
From: Michał Górny @ 2017-11-18 9:22 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Introduce a new, more flexible override API in git-r3, in replacement
of the LIVE_* API that was pretty much a legacy of git-2. This means to
solve the two major limitations of the old API:
1. The variables were based on package names without categories.
Therefore, they weren't suitable whenever two packages had the same
category. This is quite common when dealing with various programming
language bindings/reimplementations, and we can't really rely on every
new programming language inventing its own VCS.
2. The overrides weren't suitable for packages checking out multiple
repositories (LLVM, wine, glibc).
The new mode for overrides uses the repository name (as guessed
by git-r3) transformed into correct variable name. The specifically
defined variables are:
- EGIT_OVERRIDE_REPO_${NAME} -- to override the repository URI,
- EGIT_OVERRIDE_BRANCH_${NAME} -- to override the branch,
- EGIT_OVERRIDE_COMMIT_${NAME} -- to override the commit id or tag,
- EGIT_OVERRIDE_COMMIT_DATE_${NAME} -- to request last commit older than
the specified date.
---
eclass/git-r3.eclass | 55 ++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 49 insertions(+), 6 deletions(-)
diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
index caf4e8d003e0..55a987b79545 100644
--- a/eclass/git-r3.eclass
+++ b/eclass/git-r3.eclass
@@ -553,6 +553,7 @@ _git-r3_is_local_repo() {
git-r3_fetch() {
debug-print-function ${FUNCNAME} "$@"
+ # process repos first since we create repo_name from it
local repos
if [[ ${1} ]]; then
repos=( ${1} )
@@ -562,12 +563,6 @@ git-r3_fetch() {
repos=( ${EGIT_REPO_URI} )
fi
- local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}}
- local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}}
- local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}}
- local local_ref=refs/git-r3/${local_id}/__main__
- local commit_date=${4:-${EGIT_COMMIT_DATE}}
-
[[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
local r
@@ -591,6 +586,54 @@ git-r3_fetch() {
)
fi
+ # get the default values for the common variables and override them
+ local branch_name=${EGIT_BRANCH}
+ local commit_id=${2:-${EGIT_COMMIT}}
+ local commit_date=${4:-${EGIT_COMMIT_DATE}}
+
+ # support new override API for EAPI 6+
+ if ! has "${EAPI:-0}" 0 1 2 3 4 5; then
+ # get the name and do some more processing:
+ # 1) kill .git suffix,
+ # 2) underscore (remaining) non-variable characters,
+ # 3) add preceding underscore if it starts with a digit,
+ # 4) uppercase.
+ local override_name=${GIT_DIR##*/}
+ override_name=${override_name%.git}
+ override_name=${override_name//[^a-zA-Z0-9_]/_}
+ override_name=${override_name^^}
+
+ local varmap=(
+ REPO:repos
+ BRANCH:branch_name
+ COMMIT:commit_id
+ COMMIT_DATE:commit_date
+ )
+
+ local localvar livevar live_warn=
+ for localvar in "${varmap[@]}"; do
+ livevar=EGIT_OVERRIDE_${localvar%:*}_${override_name}
+ localvar=${localvar#*:}
+
+ if [[ -n ${!livevar} ]]; then
+ [[ ${localvar} == repos ]] && repos=()
+ live_warn=1
+ ewarn "Using ${livevar}=${!livevar}"
+ declare "${localvar}=${!livevar}"
+ fi
+ done
+
+ if [[ ${live_warn} ]]; then
+ ewarn "No support will be provided."
+ fi
+ fi
+
+ # set final variables after applying overrides
+ local branch=${branch_name:+refs/heads/${branch_name}}
+ local remote_ref=${commit_id:-${branch:-HEAD}}
+ local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}}
+ local local_ref=refs/git-r3/${local_id}/__main__
+
# try to fetch from the remote
local success saved_umask
if [[ ${EVCS_UMASK} ]]; then
--
2.15.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-dev] Re: [PATCH] git-r3.eclass: Support more flexible EGIT_OVERRIDE_* APIs for user
2017-11-18 9:22 [gentoo-dev] [PATCH] git-r3.eclass: Support more flexible EGIT_OVERRIDE_* APIs for user Michał Górny
@ 2017-11-19 7:48 ` Duncan
2017-11-28 9:15 ` [gentoo-dev] " Michał Górny
1 sibling, 0 replies; 3+ messages in thread
From: Duncan @ 2017-11-19 7:48 UTC (permalink / raw
To: gentoo-dev
Michał Górny posted on Sat, 18 Nov 2017 10:22:34 +0100 as excerpted:
> Introduce a new, more flexible override API in git-r3, in replacement of
> the LIVE_* API that was pretty much a legacy of git-2. This means to
> solve the two major limitations of the old API:
>
> 1. The variables were based on package names without categories.
> Therefore, they weren't suitable whenever two packages had the same
> category. This is quite common when dealing with various programming
> language bindings/reimplementations, and we can't really rely on every
> new programming language inventing its own VCS.
I always used package.env in any case, and always wished for a non-
package-unique env var name variant to make it easier to simply clone the
file and stuff the commit var as appropriate, instead of having to setup
the file and fix up BOTH the var name and its value, when I needed to
bisect a package the first time.
So a variant without the repo OR package name would be my wish, here.
> 2. The overrides weren't suitable for packages checking out multiple
> repositories (LLVM, wine, glibc).
Valid point there!
--
Duncan - List replies preferred. No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master." Richard Stallman
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-dev] [PATCH] git-r3.eclass: Support more flexible EGIT_OVERRIDE_* APIs for user
2017-11-18 9:22 [gentoo-dev] [PATCH] git-r3.eclass: Support more flexible EGIT_OVERRIDE_* APIs for user Michał Górny
2017-11-19 7:48 ` [gentoo-dev] " Duncan
@ 2017-11-28 9:15 ` Michał Górny
1 sibling, 0 replies; 3+ messages in thread
From: Michał Górny @ 2017-11-28 9:15 UTC (permalink / raw
To: gentoo-dev
W dniu sob, 18.11.2017 o godzinie 10∶22 +0100, użytkownik Michał Górny
napisał:
> Introduce a new, more flexible override API in git-r3, in replacement
> of the LIVE_* API that was pretty much a legacy of git-2. This means to
> solve the two major limitations of the old API:
>
> 1. The variables were based on package names without categories.
> Therefore, they weren't suitable whenever two packages had the same
> category. This is quite common when dealing with various programming
> language bindings/reimplementations, and we can't really rely on every
> new programming language inventing its own VCS.
>
> 2. The overrides weren't suitable for packages checking out multiple
> repositories (LLVM, wine, glibc).
>
> The new mode for overrides uses the repository name (as guessed
> by git-r3) transformed into correct variable name. The specifically
> defined variables are:
>
> - EGIT_OVERRIDE_REPO_${NAME} -- to override the repository URI,
>
> - EGIT_OVERRIDE_BRANCH_${NAME} -- to override the branch,
>
> - EGIT_OVERRIDE_COMMIT_${NAME} -- to override the commit id or tag,
>
> - EGIT_OVERRIDE_COMMIT_DATE_${NAME} -- to request last commit older than
> the specified date.
>
Merged now.
--
Best regards,
Michał Górny
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-28 9:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-18 9:22 [gentoo-dev] [PATCH] git-r3.eclass: Support more flexible EGIT_OVERRIDE_* APIs for user Michał Górny
2017-11-19 7:48 ` [gentoo-dev] " Duncan
2017-11-28 9:15 ` [gentoo-dev] " Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox