Skip to content

Commit

Permalink
Add nolfs policy
Browse files Browse the repository at this point in the history
  • Loading branch information
asherikov committed Sep 30, 2024
1 parent 98bcae7 commit 3c95e19
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 29 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test_update:
${WSHANDLER} -t ${TYPE} -r tests/update/ --jobs 2 --policy shallow update
${WSHANDLER} -t ${TYPE} --root tests/update/ status
${WSHANDLER} -t ${TYPE} --root tests/update/ -j 2 clean
${WSHANDLER} -t ${TYPE} -r tests/update/ --jobs 2 --policy shallow,rebase update
${WSHANDLER} -t ${TYPE} -r tests/update/ --jobs 2 --policy shallow,rebase,nolfs update
${WSHANDLER} -t ${TYPE} --root tests/update/ status
${WSHANDLER} -t ${TYPE} --root tests/update/ -j 2 clean
${WSHANDLER} -t ${TYPE} -r tests/update/ --jobs 2 --policy rebase update
Expand Down Expand Up @@ -63,6 +63,7 @@ test_remove:

test_init:
${WSHANDLER} -t ${TYPE} --root tests/init_${TYPE} -p shallow init git https://github.com/asherikov/staticoma.git
${WSHANDLER} -t ${TYPE} --root tests/init_${TYPE}_nolfs -p shallow,nolfs init git https://github.com/asherikov/staticoma.git

test_set_version:
${WSHANDLER} -t ${TYPE} --root tests/update/ set_version_by_url https://github.com/asherikov/qpmad.git master
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Common arguments:
-k|--keep-going {false}
List commands:
status
[-j|--jobs <NUM_THREADS> {1}] [-p|--policy {default}|shallow|rebase] update
[-j|--jobs <NUM_THREADS> {1}] [-p|--policy policy1[,policy2] ({default}|shallow|nolfs|rebase)] update
[-j|--jobs <NUM_THREADS> {1}] clean
[-p|--policy {ask}|add|show] scrape
add git <NAME> <URL> <VERSION>
Expand All @@ -53,8 +53,8 @@ List commands:
remove_by_url <URL>
[-p|--policy {keep}|replace] merge <FILENAME>
List initialization commands:
[-p|--policy {default}|shallow|rebase] clone git <URL> [<BRANCH>]
[-p|--policy {default}|shallow] init [git <URL1> ...]
[-p|--policy policy1[,policy2] ({default}|shallow|nolfs)] clone git <URL> [<BRANCH>]
[-p|--policy policy1[,policy2] ({default}|shallow|nolfs)] init [git <URL1> ...]
Repository commands:
[-j|--jobs <NUM_THREADS> {1}] [-s|-source {git}] foreach '<COMMAND>'
prune
Expand Down
8 changes: 4 additions & 4 deletions tests/update/.repos
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ repositories:
staticoma:
type: git
url: https://github.com/asherikov/staticoma.git
staticoma_master:
type: git
url: https://github.com/asherikov/staticoma.git
version: master
staticoma_commit:
type: git
url: https://github.com/asherikov/staticoma.git
Expand All @@ -18,3 +14,7 @@ repositories:
type: git
url: https://github.com/asherikov/qpmad.git
version: 1.3.0
staticoma_master:
type: git
url: https://github.com/asherikov/staticoma.git
version: master
59 changes: 38 additions & 21 deletions wshandler
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ help()

echo "List commands:"
echo " status"
echo " [-j|--jobs <NUM_THREADS> {1}] [-p|--policy {default}|shallow|rebase] update"
echo " [-j|--jobs <NUM_THREADS> {1}] [-p|--policy policy1[,policy2] ({default}|shallow|nolfs|rebase)] update"
echo " [-j|--jobs <NUM_THREADS> {1}] clean"
echo " [-p|--policy {ask}|add|show] scrape"
echo " add git <NAME> <URL> <VERSION>"
Expand All @@ -32,8 +32,8 @@ help()
echo " [-p|--policy {keep}|replace] merge <FILENAME>"

echo "List initialization commands:"
echo " [-p|--policy {default}|shallow|rebase] clone git <URL> [<BRANCH>]"
echo " [-p|--policy {default}|shallow] init [git <URL1> ...]"
echo " [-p|--policy policy1[,policy2] ({default}|shallow|nolfs)] clone git <URL> [<BRANCH>]"
echo " [-p|--policy policy1[,policy2] ({default}|shallow|nolfs)] init [git <URL1> ...]"

echo "Repository commands:"
echo " [-j|--jobs <NUM_THREADS> {1}] [-s|-source {git}] foreach '<COMMAND>'"
Expand Down Expand Up @@ -130,15 +130,20 @@ git_update()
# if we are on a branch make sure that it is updated
if (git branch --show-current | grep "${GIT_VERSION}")
then
PULL_ENV=(env)
PULL_ARGS=()
for POLICY in "${POLICIES[@]}";
do
if [ "${POLICY}" == "rebase" ]
then
PULL_ARGS+=(--rebase)
fi
case ${POLICY} in
rebase)
PULL_ARGS+=(--rebase)
;;
nolfs)
PULL_ENV+=("GIT_LFS_SKIP_SMUDGE=1")
;;
esac
done
git pull "${PULL_ARGS[@]}"
"${PULL_ENV[@]}" git pull "${PULL_ARGS[@]}"
fi
fi
popd
Expand Down Expand Up @@ -206,13 +211,20 @@ git_clone()
VERSION=$2
DIR=$3

CLONE_ENV=(env)
CLONE_ARGS=(--recurse-submodules)
for POLICY in "${POLICIES[@]}";
do
if [ "${POLICY}" == "shallow" ]
then
CLONE_ARGS+=(--depth 1 --shallow-submodules)
fi
case ${POLICY} in
shallow)
# --no-tags -- we need tags
# --single-branch -- implied by --depth
CLONE_ARGS+=(--depth 1 --shallow-submodules)
;;
nolfs)
CLONE_ENV+=("GIT_LFS_SKIP_SMUDGE=1")
;;
esac
done

SOURCE_DESTINATION=("${GIT_REPO}")
Expand All @@ -223,15 +235,15 @@ git_clone()

if [ "${VERSION}" == '-' ] || [ -z "${VERSION}" ]
then
git clone "${CLONE_ARGS[@]}" "${SOURCE_DESTINATION[@]}"
"${CLONE_ENV[@]}" git clone "${CLONE_ARGS[@]}" "${SOURCE_DESTINATION[@]}"
else
if ! (git clone "${CLONE_ARGS[@]}" --branch "${VERSION}" "${SOURCE_DESTINATION[@]}")
if ! ("${CLONE_ENV[@]}" git clone "${CLONE_ARGS[@]}" --branch "${VERSION}" "${SOURCE_DESTINATION[@]}")
then
# GIT_VERSION is a hash
# clone with history to be able to find it
git clone --recurse-submodules "${SOURCE_DESTINATION[@]}"
"${CLONE_ENV[@]}" git clone --recurse-submodules "${SOURCE_DESTINATION[@]}"
pushd "${DIR}"
git checkout "${VERSION}"
"${CLONE_ENV[@]}" git checkout "${VERSION}"
popd
fi
fi
Expand Down Expand Up @@ -316,15 +328,20 @@ dir_git_update()
# if we are on a branch make sure that it is updated
if (git branch --show-current | grep "${GIT_VERSION}")
then
PULL_ENV=(env)
PULL_ARGS=()
for POLICY in "${POLICIES[@]}";
do
if [ "${POLICY}" == "rebase" ]
then
PULL_ARGS+=(--rebase)
fi
case ${POLICY} in
rebase)
PULL_ARGS+=(--rebase)
;;
nolfs)
PULL_ENV+=("GIT_LFS_SKIP_SMUDGE=1")
;;
esac
done
git pull "${PULL_ARGS[@]}"
"${PULL_ENV[@]}" git pull "${PULL_ARGS[@]}"
fi
fi
else
Expand Down

0 comments on commit 3c95e19

Please sign in to comment.