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

Diff of /eclass/git.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.35 Revision 1.37
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2009 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/git.eclass,v 1.35 2010/01/13 20:04:19 scarabeus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/git.eclass,v 1.37 2010/01/22 09:32:57 scarabeus Exp $
4 4
5# @ECLASS: git.eclass 5# @ECLASS: git.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Tomas Chvatal <scarabeus@gentoo.org> 7# Tomas Chvatal <scarabeus@gentoo.org>
8# Donnie Berkholz <dberkholz@gentoo.org> 8# Donnie Berkholz <dberkholz@gentoo.org>
143: ${EGIT_PRUNE:=false} 143: ${EGIT_PRUNE:=false}
144 144
145# @FUNCTION: git_submodules 145# @FUNCTION: git_submodules
146# @DESCRIPTION: 146# @DESCRIPTION:
147# Internal function wrapping the submodule initialisation and update 147# Internal function wrapping the submodule initialisation and update
148git_sumbodules() { 148git_submodules() {
149 debug-print "git submodule init" 149 debug-print "git submodule init"
150 git submodule init 150 git submodule init
151 debug-print "git submodule update" 151 debug-print "git submodule update"
152 git submodule update 152 git submodule update
153}
154
155# @FUNCTION: git_branch
156# @DESCRIPTION:
157# Internal function that changes branch for the repo based on EGIT_TREE and
158# EGIT_BRANCH variables.
159git_branch() {
160 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH}
161 if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then
162 branchname=tree-${EGIT_COMMIT}
163 src=${EGIT_COMMIT}
164 fi
165 debug-print "git checkout -b ${branchname} ${src}"
166 git checkout -b ${branchname} ${src} &> /dev/null
167
168 unset branchname src
153} 169}
154 170
155# @FUNCTION: git_fetch 171# @FUNCTION: git_fetch
156# @DESCRIPTION: 172# @DESCRIPTION:
157# Gets repository from EGIT_REPO_URI and store it in specified EGIT_STORE_DIR 173# Gets repository from EGIT_REPO_URI and store it in specified EGIT_STORE_DIR
173 # folder. 189 # folder.
174 #[[ ${EGIT_COMMIT} = ${EGIT_BRANCH} ]] && \ 190 #[[ ${EGIT_COMMIT} = ${EGIT_BRANCH} ]] && \
175 # EGIT_FETCH_CMD="${EGIT_FETCH_CMD} --depth 1" 191 # EGIT_FETCH_CMD="${EGIT_FETCH_CMD} --depth 1"
176 if [[ ! -z ${EGIT_TREE} ]] ; then 192 if [[ ! -z ${EGIT_TREE} ]] ; then
177 EGIT_COMMIT=${EGIT_TREE} 193 EGIT_COMMIT=${EGIT_TREE}
178 eqawarn "Usage of deprecated EGIT_TREE variable detected." 194 ewarn "QA: Usage of deprecated EGIT_TREE variable detected."
179 eqawarn "Use EGIT_COMMIT variable instead." 195 ewarn "QA: Use EGIT_COMMIT variable instead."
180 fi 196 fi
181 197
182 # EGIT_REPO_URI is empty. 198 # EGIT_REPO_URI is empty.
183 [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty." 199 [[ -z ${EGIT_REPO_URI} ]] && die "${EGIT}: EGIT_REPO_URI is empty."
184 200
210 EGIT_CLONE_DIR="${EGIT_PROJECT}" 226 EGIT_CLONE_DIR="${EGIT_PROJECT}"
211 227
212 debug-print "${FUNCNAME}: EGIT_OPTIONS = \"${EGIT_OPTIONS}\"" 228 debug-print "${FUNCNAME}: EGIT_OPTIONS = \"${EGIT_OPTIONS}\""
213 229
214 GIT_DIR="${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}" 230 GIT_DIR="${EGIT_STORE_DIR}/${EGIT_CLONE_DIR}"
215 pushd ${EGIT_STORE_DIR} &> /dev/null
216 # we also have to remove all shallow copied repositories 231 # we also have to remove all shallow copied repositories
217 # and fetch them again 232 # and fetch them again
218 if [[ -e "${GIT_DIR}/shallow" ]]; then 233 if [[ -e "${GIT_DIR}/shallow" ]]; then
219 rm -rf "${GIT_DIR}" 234 rm -rf "${GIT_DIR}"
220 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching." 235 einfo "The ${EGIT_CLONE_DIR} was shallow copy. Refetching."
236 251
237 pushd "${GIT_DIR}" &> /dev/null 252 pushd "${GIT_DIR}" &> /dev/null
238 cursha1=$(git rev-parse origin/${EGIT_BRANCH}) 253 cursha1=$(git rev-parse origin/${EGIT_BRANCH})
239 ${elogcmd} " at the commit: ${cursha1}" 254 ${elogcmd} " at the commit: ${cursha1}"
240 255
241 git_sumbodules 256 git_submodules
242 popd &> /dev/null 257 popd &> /dev/null
243 elif [[ -n ${EGIT_OFFLINE} ]] ; then 258 elif [[ -n ${EGIT_OFFLINE} ]] ; then
244 pushd "${GIT_DIR}" &> /dev/null 259 pushd "${GIT_DIR}" &> /dev/null
245 cursha1=$(git rev-parse origin/${EGIT_BRANCH}) 260 cursha1=$(git rev-parse origin/${EGIT_BRANCH})
246 ${elogcmd} "GIT offline update -->" 261 ${elogcmd} "GIT offline update -->"
257 ${elogcmd} " repository: ${EGIT_REPO_URI}" 272 ${elogcmd} " repository: ${EGIT_REPO_URI}"
258 273
259 oldsha1=$(git rev-parse origin/${EGIT_BRANCH}) 274 oldsha1=$(git rev-parse origin/${EGIT_BRANCH})
260 275
261 debug-print "${EGIT_UPDATE_CMD} ${EGIT_OPTIONS}" 276 debug-print "${EGIT_UPDATE_CMD} ${EGIT_OPTIONS}"
277 # fix branching
278 git checkout master
279 for x in $(git branch |grep -v "* master" |tr '\n' ' '); do
280 git branch -D ${x}
281 done
262 ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} \ 282 ${EGIT_UPDATE_CMD} ${EGIT_OPTIONS} \
263 || die "${EGIT}: can't update from ${EGIT_REPO_URI}." 283 || die "${EGIT}: can't update from ${EGIT_REPO_URI}."
264 284
265 git_sumbodules 285 git_submodules
266 cursha1=$(git rev-parse origin/${EGIT_BRANCH}) 286 cursha1=$(git rev-parse origin/${EGIT_BRANCH})
267 287
268 # write out message based on the revisions 288 # write out message based on the revisions
269 if [[ ${oldsha1} != ${cursha1} ]]; then 289 if [[ ${oldsha1} != ${cursha1} ]]; then
270 ${elogcmd} " updating from commit: ${oldsha1}" 290 ${elogcmd} " updating from commit: ${oldsha1}"
295 popd &> /dev/null 315 popd &> /dev/null
296 316
297 # export the git version 317 # export the git version
298 export EGIT_VERSION="${cursha1}" 318 export EGIT_VERSION="${cursha1}"
299 319
320 # log the repo state
300 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] && elog " commit: ${EGIT_COMMIT}" 321 [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]] && elog " commit: ${EGIT_COMMIT}"
301 ${elogcmd} " branch: ${EGIT_BRANCH}" 322 ${elogcmd} " branch: ${EGIT_BRANCH}"
302 ${elogcmd} " storage directory: \"${GIT_DIR}\"" 323 ${elogcmd} " storage directory: \"${GIT_DIR}\""
303 324
304 # unpack to the ${S} 325 pushd "${GIT_DIR}" &> /dev/null
326 debug-print "rsync -rlpgo . \"${S}\""
327 time rsync -rlpgo . "${S}"
305 popd &> /dev/null 328 popd &> /dev/null
306 debug-print "git clone -l \"${GIT_DIR}\" \"${S}\""
307 git clone -l "${GIT_DIR}" "${S}"
308 329
309 # set correct branch and the tree ebuild specified
310 pushd "${S}" > /dev/null 330 pushd "${S}" &> /dev/null
311 local branchname=branch-${EGIT_BRANCH} src=origin/${EGIT_BRANCH} 331 git_branch
312 if [[ ${EGIT_COMMIT} != ${EGIT_BRANCH} ]]; then 332 # submodules always reqire net (thanks to branches changing)
313 branchname=tree-${EGIT_COMMIT} 333 [[ -n ${EGIT_OFFLINE} ]] || git_submodules
314 src=${EGIT_COMMIT}
315 fi
316 debug-print "git checkout -b ${branchname} ${src}"
317 git checkout -b ${branchname} ${src} 2>&1 > /dev/null
318 git_sumbodules
319 popd > /dev/null 334 popd &> /dev/null
320
321 unset branchname src
322 335
323 echo ">>> Unpacked to ${S}" 336 echo ">>> Unpacked to ${S}"
324} 337}
325 338
326# @FUNCTION: git_bootstrap 339# @FUNCTION: git_bootstrap

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.37

  ViewVC Help
Powered by ViewVC 1.1.20