summaryrefslogtreecommitdiff
path: root/src/lib/repo
diff options
context:
space:
mode:
authorChristian Heusel <christian@heusel.eu>2023-04-14 17:14:05 +0200
committerLevente Polyak <anthraxx@archlinux.org>2023-05-20 00:08:13 +0200
commit8e3b6bcc5b82b270f8d310865f14f2b0405eddd7 (patch)
tree82179a5d2c01a81a7e28d57f466de6e16fc68688 /src/lib/repo
parent4289be212b38cbd9a1676303224b6af5c00bd429 (diff)
downloaddevtools-8e3b6bcc5b82b270f8d310865f14f2b0405eddd7.tar.xz
pkgctl repo clone: add option to switch working tree
Add an option to call the switch command after clone. Switch to a specified version. The working tree and the index are updated to match the version. Signed-off-by: Christian Heusel <christian@heusel.eu> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'src/lib/repo')
-rw-r--r--src/lib/repo/clone.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/repo/clone.sh b/src/lib/repo/clone.sh
index dee4870..340aa69 100644
--- a/src/lib/repo/clone.sh
+++ b/src/lib/repo/clone.sh
@@ -32,12 +32,14 @@ pkgctl_repo_clone_usage() {
OPTIONS
-m, --maintainer=NAME Clone all packages of the named maintainer
+ --switch VERSION Switch the current working tree to a specified version
--universe Clone all existing packages, useful for cache warming
-h, --help Show this help text
EXAMPLES
$ ${COMMAND} libfoo linux libbar
$ ${COMMAND} --maintainer mynickname
+ $ ${COMMAND} --switch 1:1.0-2 libfoo
_EOF_
}
@@ -51,6 +53,7 @@ pkgctl_repo_clone() {
local GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_SSH}
local CLONE_ALL=0
local MAINTAINER=
+ local VERSION=
local CONFIGURE_OPTIONS=()
local pkgbases
@@ -77,6 +80,19 @@ pkgctl_repo_clone() {
MAINTAINER="${1#*=}"
shift
;;
+ --switch)
+ (( $# <= 1 )) && die "missing argument for %s" "$1"
+ # shellcheck source=src/lib/repo/switch.sh
+ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/repo/switch.sh
+ VERSION="$2"
+ shift 2
+ ;;
+ --switch=*)
+ # shellcheck source=src/lib/repo/switch.sh
+ source "${_DEVTOOLS_LIBRARY_DIR}"/lib/repo/switch.sh
+ VERSION="${1#*=}"
+ shift
+ ;;
--universe)
CLONE_ALL=1
shift
@@ -137,5 +153,9 @@ pkgctl_repo_clone() {
fi
pkgctl_repo_configure "${CONFIGURE_OPTIONS[@]}" "${pkgbase}"
+
+ if [[ -n "${VERSION}" ]]; then
+ pkgctl_repo_switch "${VERSION}" "${pkgbase}"
+ fi
done
}