Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Tue, 28 Nov 2017 09:15:13
Message-Id: 1511860487.17d7a4564177b1985e4b7e8f23a8efbc4d5c32ae.mgorny@gentoo
1 commit: 17d7a4564177b1985e4b7e8f23a8efbc4d5c32ae
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat Nov 18 09:14:31 2017 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Nov 28 09:14:47 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=17d7a456
7
8 git-r3.eclass: Support more flexible EGIT_OVERRIDE_* APIs for user
9
10 Introduce a new, more flexible override API in git-r3, in replacement
11 of the LIVE_* API that was pretty much a legacy of git-2. This means to
12 solve the two major limitations of the old API:
13
14 1. The variables were based on package names without categories.
15 Therefore, they weren't suitable whenever two packages had the same
16 category. This is quite common when dealing with various programming
17 language bindings/reimplementations, and we can't really rely on every
18 new programming language inventing its own VCS.
19
20 2. The overrides weren't suitable for packages checking out multiple
21 repositories (LLVM, wine, glibc).
22
23 The new mode for overrides uses the repository name (as guessed
24 by git-r3) transformed into correct variable name. The specifically
25 defined variables are:
26
27 - EGIT_OVERRIDE_REPO_${NAME} -- to override the repository URI,
28
29 - EGIT_OVERRIDE_BRANCH_${NAME} -- to override the branch,
30
31 - EGIT_OVERRIDE_COMMIT_${NAME} -- to override the commit id or tag,
32
33 - EGIT_OVERRIDE_COMMIT_DATE_${NAME} -- to request last commit older than
34 the specified date.
35
36 eclass/git-r3.eclass | 55 ++++++++++++++++++++++++++++++++++++++++++++++------
37 1 file changed, 49 insertions(+), 6 deletions(-)
38
39 diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass
40 index caf4e8d003e..55a987b7954 100644
41 --- a/eclass/git-r3.eclass
42 +++ b/eclass/git-r3.eclass
43 @@ -553,6 +553,7 @@ _git-r3_is_local_repo() {
44 git-r3_fetch() {
45 debug-print-function ${FUNCNAME} "$@"
46
47 + # process repos first since we create repo_name from it
48 local repos
49 if [[ ${1} ]]; then
50 repos=( ${1} )
51 @@ -562,12 +563,6 @@ git-r3_fetch() {
52 repos=( ${EGIT_REPO_URI} )
53 fi
54
55 - local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}}
56 - local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}}
57 - local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}}
58 - local local_ref=refs/git-r3/${local_id}/__main__
59 - local commit_date=${4:-${EGIT_COMMIT_DATE}}
60 -
61 [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
62
63 local r
64 @@ -591,6 +586,54 @@ git-r3_fetch() {
65 )
66 fi
67
68 + # get the default values for the common variables and override them
69 + local branch_name=${EGIT_BRANCH}
70 + local commit_id=${2:-${EGIT_COMMIT}}
71 + local commit_date=${4:-${EGIT_COMMIT_DATE}}
72 +
73 + # support new override API for EAPI 6+
74 + if ! has "${EAPI:-0}" 0 1 2 3 4 5; then
75 + # get the name and do some more processing:
76 + # 1) kill .git suffix,
77 + # 2) underscore (remaining) non-variable characters,
78 + # 3) add preceding underscore if it starts with a digit,
79 + # 4) uppercase.
80 + local override_name=${GIT_DIR##*/}
81 + override_name=${override_name%.git}
82 + override_name=${override_name//[^a-zA-Z0-9_]/_}
83 + override_name=${override_name^^}
84 +
85 + local varmap=(
86 + REPO:repos
87 + BRANCH:branch_name
88 + COMMIT:commit_id
89 + COMMIT_DATE:commit_date
90 + )
91 +
92 + local localvar livevar live_warn=
93 + for localvar in "${varmap[@]}"; do
94 + livevar=EGIT_OVERRIDE_${localvar%:*}_${override_name}
95 + localvar=${localvar#*:}
96 +
97 + if [[ -n ${!livevar} ]]; then
98 + [[ ${localvar} == repos ]] && repos=()
99 + live_warn=1
100 + ewarn "Using ${livevar}=${!livevar}"
101 + declare "${localvar}=${!livevar}"
102 + fi
103 + done
104 +
105 + if [[ ${live_warn} ]]; then
106 + ewarn "No support will be provided."
107 + fi
108 + fi
109 +
110 + # set final variables after applying overrides
111 + local branch=${branch_name:+refs/heads/${branch_name}}
112 + local remote_ref=${commit_id:-${branch:-HEAD}}
113 + local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}}
114 + local local_ref=refs/git-r3/${local_id}/__main__
115 +
116 # try to fetch from the remote
117 local success saved_umask
118 if [[ ${EVCS_UMASK} ]]; then