/[gentoo-x86]/eclass/git-r3.eclass
Gentoo

Contents of /eclass/git-r3.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24 - (hide annotations) (download)
Sun Feb 23 22:05:55 2014 UTC (7 months, 3 weeks ago) by mgorny
Branch: MAIN
Changes since 1.23: +63 -226 lines
Use complete git clones, and clone them onto the checkout directory. This makes it possible for build system to lookup all repository information as requested in bug #489100. Remove shallow clone support since it would require too much effort and make code hard to understand. Additionally obsoletes bug #489100 and git-r3 part of bug #494934.

1 mgorny 1.24 # Copyright 1999-2014 Gentoo Foundation
2 mgorny 1.1 # Distributed under the terms of the GNU General Public License v2
3 mgorny 1.24 # $Header: /var/cvsroot/gentoo-x86/eclass/git-r3.eclass,v 1.23 2013/11/15 23:03:23 mgorny Exp $
4 mgorny 1.1
5     # @ECLASS: git-r3.eclass
6     # @MAINTAINER:
7     # Michał Górny <mgorny@gentoo.org>
8     # @BLURB: Eclass for fetching and unpacking git repositories.
9     # @DESCRIPTION:
10     # Third generation eclass for easing maitenance of live ebuilds using
11 mgorny 1.24 # git as remote repository.
12 mgorny 1.1
13     case "${EAPI:-0}" in
14     0|1|2|3|4|5)
15     ;;
16     *)
17     die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
18     ;;
19     esac
20    
21     if [[ ! ${_GIT_R3} ]]; then
22    
23     inherit eutils
24    
25     fi
26    
27     EXPORT_FUNCTIONS src_unpack
28    
29     if [[ ! ${_GIT_R3} ]]; then
30    
31 mgorny 1.14 if [[ ! ${_INHERITED_BY_GIT_2} ]]; then
32 mgorny 1.24 DEPEND="dev-vcs/git"
33 mgorny 1.14 fi
34 mgorny 1.13
35 mgorny 1.1 # @ECLASS-VARIABLE: EGIT3_STORE_DIR
36     # @DESCRIPTION:
37     # Storage directory for git sources.
38     #
39     # EGIT3_STORE_DIR=${DISTDIR}/git3-src
40    
41     # @ECLASS-VARIABLE: EGIT_REPO_URI
42     # @REQUIRED
43     # @DESCRIPTION:
44     # URIs to the repository, e.g. git://foo, https://foo. If multiple URIs
45     # are provided, the eclass will consider them as fallback URIs to try
46     # if the first URI does not work.
47     #
48     # It can be overriden via env using ${PN}_LIVE_REPO variable.
49     #
50 mgorny 1.9 # Can be a whitespace-separated list or an array.
51     #
52 mgorny 1.1 # Example:
53     # @CODE
54     # EGIT_REPO_URI="git://a/b.git https://c/d.git"
55     # @CODE
56    
57     # @ECLASS-VARIABLE: EVCS_OFFLINE
58     # @DEFAULT_UNSET
59     # @DESCRIPTION:
60     # If non-empty, this variable prevents any online operations.
61    
62     # @ECLASS-VARIABLE: EGIT_BRANCH
63     # @DEFAULT_UNSET
64     # @DESCRIPTION:
65     # The branch name to check out. If unset, the upstream default (HEAD)
66     # will be used.
67     #
68     # It can be overriden via env using ${PN}_LIVE_BRANCH variable.
69    
70     # @ECLASS-VARIABLE: EGIT_COMMIT
71     # @DEFAULT_UNSET
72     # @DESCRIPTION:
73     # The tag name or commit identifier to check out. If unset, newest
74     # commit from the branch will be used. If set, EGIT_BRANCH will
75     # be ignored.
76     #
77     # It can be overriden via env using ${PN}_LIVE_COMMIT variable.
78    
79     # @ECLASS-VARIABLE: EGIT_CHECKOUT_DIR
80     # @DESCRIPTION:
81     # The directory to check the git sources out to.
82     #
83     # EGIT_CHECKOUT_DIR=${WORKDIR}/${P}
84    
85     # @FUNCTION: _git-r3_env_setup
86     # @INTERNAL
87     # @DESCRIPTION:
88     # Set the eclass variables as necessary for operation. This can involve
89     # setting EGIT_* to defaults or ${PN}_LIVE_* variables.
90     _git-r3_env_setup() {
91     debug-print-function ${FUNCNAME} "$@"
92    
93     local esc_pn livevar
94     esc_pn=${PN//[-+]/_}
95    
96     livevar=${esc_pn}_LIVE_REPO
97     EGIT_REPO_URI=${!livevar:-${EGIT_REPO_URI}}
98     [[ ${!livevar} ]] \
99     && ewarn "Using ${livevar}, no support will be provided"
100    
101     livevar=${esc_pn}_LIVE_BRANCH
102     EGIT_BRANCH=${!livevar:-${EGIT_BRANCH}}
103     [[ ${!livevar} ]] \
104     && ewarn "Using ${livevar}, no support will be provided"
105    
106     livevar=${esc_pn}_LIVE_COMMIT
107     EGIT_COMMIT=${!livevar:-${EGIT_COMMIT}}
108     [[ ${!livevar} ]] \
109     && ewarn "Using ${livevar}, no support will be provided"
110    
111     # Migration helpers. Remove them when git-2 is removed.
112    
113     if [[ ${EGIT_SOURCEDIR} ]]; then
114     eerror "EGIT_SOURCEDIR has been replaced by EGIT_CHECKOUT_DIR. While updating"
115     eerror "your ebuild, please check whether the variable is necessary at all"
116     eerror "since the default has been changed from \${S} to \${WORKDIR}/\${P}."
117     eerror "Therefore, proper setting of S may be sufficient."
118     die "EGIT_SOURCEDIR has been replaced by EGIT_CHECKOUT_DIR."
119     fi
120    
121     if [[ ${EGIT_MASTER} ]]; then
122     eerror "EGIT_MASTER has been removed. Instead, the upstream default (HEAD)"
123     eerror "is used by the eclass. Please remove the assignment or use EGIT_BRANCH"
124     eerror "as necessary."
125     die "EGIT_MASTER has been removed."
126     fi
127    
128     if [[ ${EGIT_HAS_SUBMODULES} ]]; then
129     eerror "EGIT_HAS_SUBMODULES has been removed. The eclass no longer needs"
130     eerror "to switch the clone type in order to support submodules and therefore"
131     eerror "submodules are detected and fetched automatically."
132     die "EGIT_HAS_SUBMODULES is no longer necessary."
133     fi
134    
135     if [[ ${EGIT_PROJECT} ]]; then
136     eerror "EGIT_PROJECT has been removed. Instead, the eclass determines"
137     eerror "the local clone path using path in canonical EGIT_REPO_URI."
138     eerror "If the current algorithm causes issues for you, please report a bug."
139     die "EGIT_PROJECT is no longer necessary."
140     fi
141    
142     if [[ ${EGIT_BOOTSTRAP} ]]; then
143     eerror "EGIT_BOOTSTRAP has been removed. Please create proper src_prepare()"
144     eerror "instead."
145     die "EGIT_BOOTSTRAP has been removed."
146     fi
147    
148     if [[ ${EGIT_NOUNPACK} ]]; then
149     eerror "EGIT_NOUNPACK has been removed. The eclass no longer calls default"
150     eerror "unpack function. If necessary, please declare proper src_unpack()."
151     die "EGIT_NOUNPACK has been removed."
152     fi
153     }
154    
155     # @FUNCTION: _git-r3_set_gitdir
156     # @USAGE: <repo-uri>
157     # @INTERNAL
158     # @DESCRIPTION:
159     # Obtain the local repository path and set it as GIT_DIR. Creates
160     # a new repository if necessary.
161     #
162     # <repo-uri> may be used to compose the path. It should therefore be
163     # a canonical URI to the repository.
164     _git-r3_set_gitdir() {
165     debug-print-function ${FUNCNAME} "$@"
166    
167     local repo_name=${1#*://*/}
168    
169 mgorny 1.7 # strip the trailing slash
170     repo_name=${repo_name%/}
171    
172 mgorny 1.1 # strip common prefixes to make paths more likely to match
173     # e.g. git://X/Y.git vs https://X/git/Y.git
174     # (but just one of the prefixes)
175     case "${repo_name}" in
176 mgorny 1.8 # gnome.org... who else?
177     browse/*) repo_name=${repo_name#browse/};;
178 mgorny 1.1 # cgit can proxy requests to git
179     cgit/*) repo_name=${repo_name#cgit/};;
180     # pretty common
181     git/*) repo_name=${repo_name#git/};;
182     # gentoo.org
183     gitroot/*) repo_name=${repo_name#gitroot/};;
184     # google code, sourceforge
185     p/*) repo_name=${repo_name#p/};;
186     # kernel.org
187     pub/scm/*) repo_name=${repo_name#pub/scm/};;
188     esac
189     # ensure a .git suffix, same reason
190     repo_name=${repo_name%.git}.git
191     # now replace all the slashes
192     repo_name=${repo_name//\//_}
193    
194     local distdir=${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}
195     : ${EGIT3_STORE_DIR:=${distdir}/git3-src}
196    
197     GIT_DIR=${EGIT3_STORE_DIR}/${repo_name}
198    
199     if [[ ! -d ${EGIT3_STORE_DIR} ]]; then
200     (
201     addwrite /
202 mgorny 1.17 mkdir -m0755 -p "${EGIT3_STORE_DIR}" || die
203 mgorny 1.1 ) || die "Unable to create ${EGIT3_STORE_DIR}"
204     fi
205    
206     addwrite "${EGIT3_STORE_DIR}"
207 mgorny 1.24 if [[ -e ${GIT_DIR}/shallow ]]; then
208     einfo "${GIT_DIR} was a shallow clone, recreating..."
209     rm -r "${GIT_DIR}" || die
210     fi
211 mgorny 1.1 if [[ ! -d ${GIT_DIR} ]]; then
212     mkdir "${GIT_DIR}" || die
213     git init --bare || die
214     fi
215     }
216    
217     # @FUNCTION: _git-r3_set_submodules
218     # @USAGE: <file-contents>
219     # @INTERNAL
220     # @DESCRIPTION:
221     # Parse .gitmodules contents passed as <file-contents>
222     # as in "$(cat .gitmodules)"). Composes a 'submodules' array that
223     # contains in order (name, URL, path) for each submodule.
224     _git-r3_set_submodules() {
225     debug-print-function ${FUNCNAME} "$@"
226    
227     local data=${1}
228    
229     # ( name url path ... )
230     submodules=()
231    
232     local l
233     while read l; do
234     # submodule.<path>.path=<path>
235     # submodule.<path>.url=<url>
236     [[ ${l} == submodule.*.url=* ]] || continue
237    
238     l=${l#submodule.}
239     local subname=${l%%.url=*}
240    
241 mgorny 1.15 # skip modules that have 'update = none', bug #487262.
242     local upd=$(echo "${data}" | git config -f /dev/fd/0 \
243 mgorny 1.18 submodule."${subname}".update)
244 mgorny 1.15 [[ ${upd} == none ]] && continue
245    
246 mgorny 1.1 submodules+=(
247     "${subname}"
248     "$(echo "${data}" | git config -f /dev/fd/0 \
249 mgorny 1.17 submodule."${subname}".url || die)"
250 mgorny 1.1 "$(echo "${data}" | git config -f /dev/fd/0 \
251 mgorny 1.17 submodule."${subname}".path || die)"
252 mgorny 1.1 )
253 mgorny 1.17 done < <(echo "${data}" | git config -f /dev/fd/0 -l || die)
254 mgorny 1.1 }
255    
256 mgorny 1.23 # @FUNCTION: _git-r3_is_local_repo
257     # @USAGE: <repo-uri>
258     # @INTERNAL
259     # @DESCRIPTION:
260     # Determine whether the given URI specifies a local (on-disk)
261     # repository.
262     _git-r3_is_local_repo() {
263     debug-print-function ${FUNCNAME} "$@"
264    
265     local uri=${1}
266    
267     [[ ${uri} == file://* || ${uri} == /* ]]
268     }
269    
270 mgorny 1.1 # @FUNCTION: git-r3_fetch
271     # @USAGE: [<repo-uri> [<remote-ref> [<local-id>]]]
272     # @DESCRIPTION:
273     # Fetch new commits to the local clone of repository.
274     #
275     # <repo-uri> specifies the repository URIs to fetch from, as a space-
276     # -separated list. The first URI will be used as repository group
277     # identifier and therefore must be used consistently. When not
278     # specified, defaults to ${EGIT_REPO_URI}.
279     #
280     # <remote-ref> specifies the remote ref or commit id to fetch.
281     # It is preferred to use 'refs/heads/<branch-name>' for branches
282     # and 'refs/tags/<tag-name>' for tags. Other options are 'HEAD'
283     # for upstream default branch and hexadecimal commit SHA1. Defaults
284     # to the first of EGIT_COMMIT, EGIT_BRANCH or literal 'HEAD' that
285     # is set to a non-null value.
286     #
287     # <local-id> specifies the local branch identifier that will be used to
288     # locally store the fetch result. It should be unique to multiple
289     # fetches within the repository that can be performed at the same time
290 mgorny 1.20 # (including parallel merges). It defaults to ${CATEGORY}/${PN}/${SLOT%/*}.
291 mgorny 1.1 # This default should be fine unless you are fetching multiple trees
292     # from the same repository in the same ebuild.
293     #
294     # The fetch operation will affect the EGIT_STORE only. It will not touch
295     # the working copy, nor export any environment variables.
296     # If the repository contains submodules, they will be fetched
297     # recursively.
298     git-r3_fetch() {
299     debug-print-function ${FUNCNAME} "$@"
300    
301 mgorny 1.16 [[ ${EVCS_OFFLINE} ]] && return
302    
303 mgorny 1.11 local repos
304     if [[ ${1} ]]; then
305     repos=( ${1} )
306     elif [[ $(declare -p EGIT_REPO_URI) == "declare -a"* ]]; then
307     repos=( "${EGIT_REPO_URI[@]}" )
308     else
309     repos=( ${EGIT_REPO_URI} )
310 mgorny 1.9 fi
311    
312 mgorny 1.1 local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}}
313     local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}}
314 mgorny 1.20 local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}}
315 mgorny 1.24 local local_ref=refs/git-r3/${local_id}/__main__
316 mgorny 1.1
317     [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
318    
319     local -x GIT_DIR
320 mgorny 1.9 _git-r3_set_gitdir "${repos[0]}"
321 mgorny 1.1
322     # try to fetch from the remote
323     local r success
324 mgorny 1.9 for r in "${repos[@]}"; do
325 mgorny 1.24 einfo "Fetching ${r} ..."
326 mgorny 1.1
327 mgorny 1.24 local fetch_command=(
328     git fetch --prune "${r}"
329     # mirror the remote branches as local branches
330     "refs/heads/*:refs/heads/*"
331     # pull tags explicitly in order to prune them properly
332     "refs/tags/*:refs/tags/*"
333 mgorny 1.1 )
334    
335 mgorny 1.24 set -- "${fetch_command[@]}"
336     echo "${@}" >&2
337     if "${@}"; then
338     # now let's see what the user wants from us
339     local full_remote_ref=$(
340     git rev-parse --verify --symbolic-full-name "${remote_ref}"
341     )
342    
343     if [[ ${full_remote_ref} ]]; then
344     # when we are given a ref, create a symbolic ref
345     # so that we preserve the actual argument
346     set -- git symbolic-ref "${local_ref}" "${full_remote_ref}"
347 mgorny 1.3 else
348 mgorny 1.24 # otherwise, we were likely given a commit id
349     set -- git update-ref --no-deref "${local_ref}" "${remote_ref}"
350 mgorny 1.2 fi
351    
352 mgorny 1.24 echo "${@}" >&2
353     if ! "${@}"; then
354     die "Referencing ${remote_ref} failed (wrong ref?)."
355 mgorny 1.1 fi
356    
357     success=1
358     break
359     fi
360     done
361     [[ ${success} ]] || die "Unable to fetch from any of EGIT_REPO_URI"
362    
363     # recursively fetch submodules
364     if git cat-file -e "${local_ref}":.gitmodules &>/dev/null; then
365     local submodules
366     _git-r3_set_submodules \
367     "$(git cat-file -p "${local_ref}":.gitmodules || die)"
368    
369     while [[ ${submodules[@]} ]]; do
370     local subname=${submodules[0]}
371     local url=${submodules[1]}
372     local path=${submodules[2]}
373     local commit=$(git rev-parse "${local_ref}:${path}")
374    
375     if [[ ! ${commit} ]]; then
376     die "Unable to get commit id for submodule ${subname}"
377     fi
378 mgorny 1.19 if [[ ${url} == ./* || ${url} == ../* ]]; then
379     local subrepos=( "${repos[@]/%//${url}}" )
380     else
381     local subrepos=( "${url}" )
382     fi
383 mgorny 1.1
384 mgorny 1.19 git-r3_fetch "${subrepos[*]}" "${commit}" "${local_id}/${subname}"
385 mgorny 1.1
386     submodules=( "${submodules[@]:3}" ) # shift
387     done
388     fi
389     }
390    
391     # @FUNCTION: git-r3_checkout
392     # @USAGE: [<repo-uri> [<checkout-path> [<local-id>]]]
393     # @DESCRIPTION:
394     # Check the previously fetched tree to the working copy.
395     #
396     # <repo-uri> specifies the repository URIs, as a space-separated list.
397     # The first URI will be used as repository group identifier
398     # and therefore must be used consistently with git-r3_fetch.
399     # The remaining URIs are not used and therefore may be omitted.
400     # When not specified, defaults to ${EGIT_REPO_URI}.
401     #
402     # <checkout-path> specifies the path to place the checkout. It defaults
403     # to ${EGIT_CHECKOUT_DIR} if set, otherwise to ${WORKDIR}/${P}.
404     #
405     # <local-id> needs to specify the local identifier that was used
406     # for respective git-r3_fetch.
407     #
408     # The checkout operation will write to the working copy, and export
409     # the repository state into the environment. If the repository contains
410     # submodules, they will be checked out recursively.
411     git-r3_checkout() {
412     debug-print-function ${FUNCNAME} "$@"
413    
414 mgorny 1.11 local repos
415     if [[ ${1} ]]; then
416     repos=( ${1} )
417     elif [[ $(declare -p EGIT_REPO_URI) == "declare -a"* ]]; then
418     repos=( "${EGIT_REPO_URI[@]}" )
419     else
420     repos=( ${EGIT_REPO_URI} )
421 mgorny 1.9 fi
422    
423 mgorny 1.1 local out_dir=${2:-${EGIT_CHECKOUT_DIR:-${WORKDIR}/${P}}}
424 mgorny 1.20 local local_id=${3:-${CATEGORY}/${PN}/${SLOT%/*}}
425 mgorny 1.1
426 mgorny 1.24 local -x GIT_DIR
427 mgorny 1.9 _git-r3_set_gitdir "${repos[0]}"
428 mgorny 1.1
429     einfo "Checking out ${repos[0]} to ${out_dir} ..."
430    
431 mgorny 1.24 if ! git cat-file -e refs/git-r3/"${local_id}"/__main__; then
432 mgorny 1.1 if [[ ${EVCS_OFFLINE} ]]; then
433     die "No local clone of ${repos[0]}. Unable to work with EVCS_OFFLINE."
434     else
435     die "Logic error: no local clone of ${repos[0]}. git-r3_fetch not used?"
436     fi
437     fi
438 mgorny 1.24 local remote_ref=$(
439     git symbolic-ref --quiet refs/git-r3/"${local_id}"/__main__
440     )
441     local new_commit_id=$(
442     git rev-parse --verify refs/git-r3/"${local_id}"/__main__
443     )
444 mgorny 1.1
445 mgorny 1.24 set -- git clone --quiet --shared --no-checkout "${GIT_DIR}" "${out_dir}"/
446 mgorny 1.1 echo "${@}" >&2
447 mgorny 1.24 "${@}" || die "git clone (for checkout) failed"
448 mgorny 1.22
449 mgorny 1.24 git-r3_sub_checkout() {
450     local -x GIT_DIR=${out_dir}/.git
451     local -x GIT_WORK_TREE=${out_dir}
452    
453     set -- git checkout --quiet
454     if [[ ${remote_ref} ]]; then
455     set -- "${@}" "${remote_ref#refs/heads/}"
456     else
457     set -- "${@}" "${new_commit_id}"
458     fi
459     echo "${@}" >&2
460     "${@}" || die "git checkout ${remote_ref:-${new_commit_id}} failed"
461     }
462     git-r3_sub_checkout
463 mgorny 1.22
464 mgorny 1.1 local old_commit_id=$(
465 mgorny 1.24 git rev-parse --quiet --verify refs/git-r3/"${local_id}"/__old__
466 mgorny 1.1 )
467     if [[ ! ${old_commit_id} ]]; then
468     echo "GIT NEW branch -->"
469     echo " repository: ${repos[0]}"
470     echo " at the commit: ${new_commit_id}"
471     else
472 mgorny 1.24 # diff against previous revision
473 mgorny 1.1 echo "GIT update -->"
474     echo " repository: ${repos[0]}"
475     # write out message based on the revisions
476     if [[ "${old_commit_id}" != "${new_commit_id}" ]]; then
477     echo " updating from commit: ${old_commit_id}"
478     echo " to commit: ${new_commit_id}"
479    
480     git --no-pager diff --stat \
481     ${old_commit_id}..${new_commit_id}
482     else
483     echo " at the commit: ${new_commit_id}"
484     fi
485     fi
486 mgorny 1.24 git update-ref --no-deref refs/git-r3/"${local_id}"/{__old__,__main__} || die
487 mgorny 1.1
488     # recursively checkout submodules
489 mgorny 1.24 if [[ -f ${out_dir}/.gitmodules ]]; then
490 mgorny 1.1 local submodules
491     _git-r3_set_submodules \
492 mgorny 1.24 "$(<"${out_dir}"/.gitmodules)"
493 mgorny 1.1
494     while [[ ${submodules[@]} ]]; do
495     local subname=${submodules[0]}
496     local url=${submodules[1]}
497     local path=${submodules[2]}
498    
499 mgorny 1.19 if [[ ${url} == ./* || ${url} == ../* ]]; then
500     url=${repos[0]%%/}/${url}
501     fi
502    
503 mgorny 1.24 git-r3_checkout "${url}" "${out_dir}/${path}" \
504 mgorny 1.1 "${local_id}/${subname}"
505    
506     submodules=( "${submodules[@]:3}" ) # shift
507     done
508     fi
509    
510     # keep this *after* submodules
511     export EGIT_DIR=${GIT_DIR}
512     export EGIT_VERSION=${new_commit_id}
513     }
514    
515     # @FUNCTION: git-r3_peek_remote_ref
516     # @USAGE: [<repo-uri> [<remote-ref>]]
517     # @DESCRIPTION:
518     # Peek the reference in the remote repository and print the matching
519     # (newest) commit SHA1.
520     #
521     # <repo-uri> specifies the repository URIs to fetch from, as a space-
522     # -separated list. When not specified, defaults to ${EGIT_REPO_URI}.
523     #
524     # <remote-ref> specifies the remote ref to peek. It is preferred to use
525     # 'refs/heads/<branch-name>' for branches and 'refs/tags/<tag-name>'
526     # for tags. Alternatively, 'HEAD' may be used for upstream default
527     # branch. Defaults to the first of EGIT_COMMIT, EGIT_BRANCH or literal
528     # 'HEAD' that is set to a non-null value.
529     #
530     # The operation will be done purely on the remote, without using local
531     # storage. If commit SHA1 is provided as <remote-ref>, the function will
532     # fail due to limitations of git protocol.
533     #
534     # On success, the function returns 0 and writes hexadecimal commit SHA1
535     # to stdout. On failure, the function returns 1.
536     git-r3_peek_remote_ref() {
537     debug-print-function ${FUNCNAME} "$@"
538    
539 mgorny 1.11 local repos
540     if [[ ${1} ]]; then
541     repos=( ${1} )
542     elif [[ $(declare -p EGIT_REPO_URI) == "declare -a"* ]]; then
543     repos=( "${EGIT_REPO_URI[@]}" )
544     else
545     repos=( ${EGIT_REPO_URI} )
546 mgorny 1.9 fi
547    
548 mgorny 1.1 local branch=${EGIT_BRANCH:+refs/heads/${EGIT_BRANCH}}
549     local remote_ref=${2:-${EGIT_COMMIT:-${branch:-HEAD}}}
550    
551     [[ ${repos[@]} ]] || die "No URI provided and EGIT_REPO_URI unset"
552    
553     local r success
554 mgorny 1.9 for r in "${repos[@]}"; do
555 mgorny 1.1 einfo "Peeking ${remote_ref} on ${r} ..." >&2
556    
557     local is_branch lookup_ref
558     if [[ ${remote_ref} == refs/heads/* || ${remote_ref} == HEAD ]]
559     then
560     is_branch=1
561     lookup_ref=${remote_ref}
562     else
563     # ls-remote by commit is going to fail anyway,
564     # so we may as well pass refs/tags/ABCDEF...
565     lookup_ref=refs/tags/${remote_ref}
566     fi
567    
568     # split on whitespace
569     local ref=(
570     $(git ls-remote "${r}" "${lookup_ref}")
571     )
572    
573     if [[ ${ref[0]} ]]; then
574     echo "${ref[0]}"
575     return 0
576     fi
577     done
578    
579     return 1
580     }
581    
582     git-r3_src_fetch() {
583     debug-print-function ${FUNCNAME} "$@"
584    
585     if [[ ! ${EGIT3_STORE_DIR} && ${EGIT_STORE_DIR} ]]; then
586     ewarn "You have set EGIT_STORE_DIR but not EGIT3_STORE_DIR. Please consider"
587     ewarn "setting EGIT3_STORE_DIR for git-r3.eclass. It is recommended to use"
588     ewarn "a different directory than EGIT_STORE_DIR to ease removing old clones"
589     ewarn "when git-2 eclass becomes deprecated."
590     fi
591    
592     _git-r3_env_setup
593     git-r3_fetch
594     }
595    
596     git-r3_src_unpack() {
597     debug-print-function ${FUNCNAME} "$@"
598    
599     _git-r3_env_setup
600     git-r3_src_fetch
601     git-r3_checkout
602     }
603    
604     # https://bugs.gentoo.org/show_bug.cgi?id=482666
605     git-r3_pkg_outofdate() {
606     debug-print-function ${FUNCNAME} "$@"
607    
608     local new_commit_id=$(git-r3_peek_remote_ref)
609     ewarn "old: ${EGIT_VERSION}"
610     ewarn "new: ${new_commit_id}"
611     [[ ${new_commit_id} && ${old_commit_id} ]] || return 2
612    
613     [[ ${EGIT_VERSION} != ${new_commit_id} ]]
614     }
615    
616     _GIT_R3=1
617     fi

  ViewVC Help
Powered by ViewVC 1.1.20