Skip to content

Commit 9ed1a1b

Browse files
author
Jared Murrell
committed
added support for skipping submodules
1 parent baefd65 commit 9ed1a1b

2 files changed

Lines changed: 69 additions & 64 deletions

File tree

_functions.sh

Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -203,78 +203,81 @@ function _discover_submodules()
203203
unset IGNORE_DIRS SUBMODULES ACTIONS SELECTION SUBDIRS choices options MENU FLAGS
204204
_get_svn_layout
205205
clear
206-
echo "Discovering potential submodule candidates..."
207-
# Get the potential list of submodules, with branches, tags and trunk
208-
svn -R list ${REPO_URL} ${SVN_OPTIONS}|grep -E '(/trunk/$|/branches/$|/tags/$)' > /tmp/submodules.txt
209-
# it turns out, some folks have .git in their repos, and this falsely
210-
# identifies those as submodules. Let's remove those entries and not
211-
# present the user with the option to migrate them
212-
sed -i 's/\/.git\//d' /tmp/submodules.txt
213-
# Remove empty "trunk", "tags" and "branches" from the list of potentials
214-
for DIR in $(cat /tmp/submodules.txt);
215-
do
216-
FILES=$(svn list ${REPO_URL}/${DIR} ${SVN_OPTIONS})
217-
if [[ ${#FILES} -le 1 ]]
218-
then
219-
sed -i "s/${DIR}/d" /tmp/submodules.txt
220-
fi
221-
done
222-
# Get the path to the submodules
223-
export SUBMODULES=$(grep -E '(/trunk/$|/branches/$|/tags/$)' /tmp/submodules.txt|\
224-
sed -e 's/trunk\/$//' -e 's/tags\/$//' -e 's/branches\/$//'|sort|uniq)
225-
226-
# Print a report of the discovered submodules
227-
if [[ ${#SUBMODULES} -le 4 ]]
206+
if [[ ${ENABLE_SUBMODULES} ]]
228207
then
229-
echo "There were no nested repositories discovered"
230-
else
231-
options=($(echo ${SUBMODULES}))
232-
#Actions to take based on selection
233-
function ACTIONS {
234-
for NUM in ${!options[@]}; do
235-
[[ ${choices[NUM]} ]] && SUBDIRS+="${options[NUM]} "
236-
done
237-
if [[ ! -z ${SUBDIRS} ]]
208+
echo "Discovering potential submodule candidates..."
209+
# Get the potential list of submodules, with branches, tags and trunk
210+
svn -R list ${REPO_URL} ${SVN_OPTIONS}|grep -E '(/trunk/$|/branches/$|/tags/$)' > /tmp/submodules.txt
211+
# it turns out, some folks have .git in their repos, and this falsely
212+
# identifies those as submodules. Let's remove those entries and not
213+
# present the user with the option to migrate them
214+
sed -i 's/\/.git\//d' /tmp/submodules.txt
215+
# Remove empty "trunk", "tags" and "branches" from the list of potentials
216+
for DIR in $(cat /tmp/submodules.txt);
217+
do
218+
FILES=$(svn list ${REPO_URL}/${DIR} ${SVN_OPTIONS})
219+
if [[ ${#FILES} -le 1 ]]
238220
then
239-
export IGNORE_DIRS=$(echo "'^("${SUBDIRS}")$'"|sed -e 's/ /|/g;s/\/|)/\/)/')
240-
export FLAGS+=" --ignore-paths ${IGNORE_DIRS}"
221+
sed -i "s/${DIR}/d" /tmp/submodules.txt
241222
fi
242-
}
243-
#Variables
244-
ERROR=" "
245-
#Clear screen for menu
246-
clear
247-
#Menu function
248-
function MENU {
249-
_print_banner "We have discovered the following folders that contain" \
250-
"branches, tags, or trunk. This typically means that teams are using" \
251-
"them as separate repositories, but there is no real method of" \
252-
"discovering this, outside of the 'svn:externals' property, which is" \
253-
"often not used. Please review the following folders and select which" \
254-
"ones are to be treated as git submodules"
255-
echo ""
256-
echo "Discovered Folders"
223+
done
224+
# Get the path to the submodules
225+
export SUBMODULES=$(grep -E '(/trunk/$|/branches/$|/tags/$)' /tmp/submodules.txt|\
226+
sed -e 's/trunk\/$//' -e 's/tags\/$//' -e 's/branches\/$//'|sort|uniq)
227+
228+
# Print a report of the discovered submodules
229+
if [[ ${#SUBMODULES} -le 4 ]]
230+
then
231+
echo "There were no nested repositories discovered"
232+
else
233+
options=($(echo ${SUBMODULES}))
234+
#Actions to take based on selection
235+
function ACTIONS {
257236
for NUM in ${!options[@]}; do
258-
echo "[""${choices[NUM]:- }""]" $(( NUM+1 ))") ${options[NUM]}"
237+
[[ ${choices[NUM]} ]] && SUBDIRS+="${options[NUM]} "
259238
done
260-
echo "$ERROR"
261-
}
262-
#Menu loop
263-
while MENU && read -e -p "Select the desired options using their number (again to uncheck, ENTER when done): " -n1 SELECTION && [[ -n "${SELECTION}" ]]; do
239+
if [[ ! -z ${SUBDIRS} ]]
240+
then
241+
export IGNORE_DIRS=$(echo "'^("${SUBDIRS}")$'"|sed -e 's/ /|/g;s/\/|)/\/)/')
242+
export FLAGS+=" --ignore-paths ${IGNORE_DIRS}"
243+
fi
244+
}
245+
#Variables
246+
ERROR=" "
247+
#Clear screen for menu
264248
clear
265-
if [[ "${SELECTION}" == *[[:digit:]]* && ${SELECTION} -ge 1 && ${SELECTION} -le ${#options[@]} ]]; then
266-
(( SELECTION-- ))
267-
if [[ "${choices[SELECTION]}" == "+" ]]; then
268-
choices[SELECTION]=""
249+
#Menu function
250+
function MENU {
251+
_print_banner "We have discovered the following folders that contain" \
252+
"branches, tags, or trunk. This typically means that teams are using" \
253+
"them as separate repositories, but there is no real method of" \
254+
"discovering this, outside of the 'svn:externals' property, which is" \
255+
"often not used. Please review the following folders and select which" \
256+
"ones are to be treated as git submodules"
257+
echo ""
258+
echo "Discovered Folders"
259+
for NUM in ${!options[@]}; do
260+
echo "[""${choices[NUM]:- }""]" $(( NUM+1 ))") ${options[NUM]}"
261+
done
262+
echo "$ERROR"
263+
}
264+
#Menu loop
265+
while MENU && read -e -p "Select the desired options using their number (again to uncheck, ENTER when done): " -n1 SELECTION && [[ -n "${SELECTION}" ]]; do
266+
clear
267+
if [[ "${SELECTION}" == *[[:digit:]]* && ${SELECTION} -ge 1 && ${SELECTION} -le ${#options[@]} ]]; then
268+
(( SELECTION-- ))
269+
if [[ "${choices[SELECTION]}" == "+" ]]; then
270+
choices[SELECTION]=""
271+
else
272+
choices[SELECTION]="+"
273+
fi
274+
ERROR=" "
269275
else
270-
choices[SELECTION]="+"
276+
ERROR="Invalid option: ${SELECTION}"
271277
fi
272-
ERROR=" "
273-
else
274-
ERROR="Invalid option: ${SELECTION}"
275-
fi
276-
done
277-
ACTIONS
278+
done
279+
ACTIONS
280+
fi
278281
fi
279282
}
280283

settings.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ SVN_PASSWORD=anonymous
1616
CONVERT_HISTORY=true
1717
## Max file size for the repo. Default=100MB
1818
MAX_FILE_SIZE=100
19+
## Find and migrate nested repositories?
20+
ENABLE_SUBMODULES=false

0 commit comments

Comments
 (0)