Skip to content

Commit cde55a0

Browse files
committed
Merge branch 'develop' of git-ftp into test-uploading-heaps
2 parents c3b79ab + 23171d6 commit cde55a0

File tree

3 files changed

+103
-9
lines changed

3 files changed

+103
-9
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
Version 1.0.0-rc.2
2+
==================
3+
4+
mkllnk:
5+
* Added more tests, tests clean up and improvements. See README.md in /tests.
6+
* Improved docs.
7+
8+
Jason Woof, mkllnk:
9+
* Fixed .git-ftp-include split lines on whitespace.
10+
* Fixed .git-ftp-include will not upload files that are a substr of another path being uploaded.
11+
12+
René Moser:
13+
* Added netrc in docs.
14+
* Fixed sha1 not updated if amended.
15+
116
Version 1.0.0-rc.1
217
==================
318

git-ftp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
readonly DEFAULT_PROTOCOL="ftp"
2525
readonly REMOTE_LCK_FILE="$(basename "$0").lck"
2626
readonly SYSTEM="$(uname)"
27-
readonly VERSION='1.0.0-rc.1'
27+
readonly VERSION='1.0.0-rc.2'
2828

2929
# ------------------------------------------------------------
3030
# Defaults
@@ -565,20 +565,21 @@ set_changed_files() {
565565
if [ -f '.git-ftp-include' ]; then
566566
grep -v '^#.*$\|^\s*$' '.git-ftp-include' | tr -d '\r' > '.git-ftp-include-tmp'
567567

568-
for LINE in $(grep '^!' '.git-ftp-include-tmp')
568+
grep '^!' '.git-ftp-include-tmp' | while read LINE
569569
do
570570
FILE_STATUS='M'
571571
FILE_PAIR=$(echo "$LINE" | sed 's/^!//')
572572
echo "$FILE_STATUS $FILE_PAIR" >> '.git-ftp-tmp'
573573
done
574574

575-
for LINE in $(grep ':' '.git-ftp-include-tmp')
575+
grep ':' '.git-ftp-include-tmp' | while read LINE
576576
do
577577
OIFS="$IFS"
578578
IFS=":"
579579
FILE_PAIR=($LINE)
580580
IFS="$OIFS"
581-
if [[ $(grep -F "${FILE_PAIR[1]}" '.git-ftp-tmp') && ! $(grep -F "${FILE_PAIR[0]}" '.git-ftp-tmp') ]]; then
581+
cat .git-ftp-tmp | tr '\t' ' ' | cut -f2- -d ' ' > .git-ftp-tmp-files
582+
if [[ $(grep -Fx "${FILE_PAIR[1]}" '.git-ftp-tmp-files') && ! $(grep -Fx "${FILE_PAIR[0]}" '.git-ftp-tmp-files') ]]; then
582583
DELETE_COUNT=0
583584
MODIFY_COUNT=0
584585

@@ -616,6 +617,7 @@ set_changed_files() {
616617
fi
617618

618619
rm -f '.git-ftp-tmp'
620+
rm -f '.git-ftp-tmp-files'
619621
rm -f '.git-ftp-include-tmp'
620622
rm -f '.git-ftp-ignore-tmp'
621623

tests/git-ftp-test.sh

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/bin/sh
22

33
oneTimeSetUp() {
4-
BASE_PATH=$(readlink -f $TESTDIR/..)/
5-
# Maybe this is more robust?
6-
#BASE_PATH=$TESTDIR/../
4+
cd "$TESTDIR/../"
75

8-
GIT_FTP_CMD="${BASE_PATH}git-ftp"
6+
GIT_FTP_CMD="$(pwd)/git-ftp"
97
: ${GIT_FTP_USER=ftp}
108
: ${GIT_FTP_PASSWD=}
119
: ${GIT_FTP_ROOT=localhost/}
@@ -57,7 +55,7 @@ test_displays_usage() {
5755

5856
test_prints_version() {
5957
version=$($GIT_FTP_CMD 2>&1 --version)
60-
assertEquals = "git-ftp version 1.0.0-rc.1" "$version"
58+
assertEquals = "git-ftp version 1.0.0-rc.2" "$version"
6159
}
6260

6361
test_inits_and_pushes() {
@@ -261,6 +259,32 @@ test_ignore_dir() {
261259
assertTrue 'test failed: wrong dir was ignored' "remote_file_exists 'dir 2/test 2.txt'"
262260
}
263261

262+
test_ignore_pattern() {
263+
cd $GIT_PROJECT_PATH
264+
echo "test" > .git-ftp-ignore
265+
266+
init=$($GIT_FTP_CMD init -u $GIT_FTP_USER -p $GIT_FTP_PASSWD $GIT_FTP_URL)
267+
268+
for i in 1 2 3 4 5
269+
do
270+
assertFalse 'test failed: was not ignored' "remote_file_exists 'test $i.txt'"
271+
done;
272+
}
273+
274+
test_ignore_pattern_single() {
275+
cd $GIT_PROJECT_PATH
276+
echo 'test' > 'test'
277+
echo "^test$" > .git-ftp-ignore
278+
279+
init=$($GIT_FTP_CMD init -u $GIT_FTP_USER -p $GIT_FTP_PASSWD $GIT_FTP_URL)
280+
281+
assertFalse 'test failed: was not ignored' "remote_file_exists 'test'"
282+
for i in 1 2 3 4 5
283+
do
284+
assertTrue 'test failed: was ignored' "remote_file_exists 'test $i.txt'"
285+
done;
286+
}
287+
264288
test_ignore_wildcard_files() {
265289
cd $GIT_PROJECT_PATH
266290
echo "test.*\.txt" > .git-ftp-ignore
@@ -285,6 +309,17 @@ test_include_init() {
285309
assertTrue 'unversioned.txt was not uploaded' "remote_file_exists 'unversioned.txt'"
286310
}
287311

312+
test_include_whitespace_init() {
313+
cd $GIT_PROJECT_PATH
314+
echo 'unversioned' > unversioned.txt
315+
echo 'unversioned.txt' >> .gitignore
316+
echo 'unversioned.txt:test X.txt' > .git-ftp-include
317+
git add .
318+
git commit -m 'unversioned file unversioned.txt should not be uploaded. test X.txt does not exist.' > /dev/null
319+
init=$($GIT_FTP_CMD init -u $GIT_FTP_USER -p $GIT_FTP_PASSWD $GIT_FTP_URL)
320+
assertFalse 'unversioned.txt was uploaded' "remote_file_exists 'unversioned.txt'"
321+
}
322+
288323
test_include_push() {
289324
cd $GIT_PROJECT_PATH
290325
init=$($GIT_FTP_CMD init -u $GIT_FTP_USER -p $GIT_FTP_PASSWD $GIT_FTP_URL)
@@ -325,6 +360,48 @@ test_include_ignore_push() {
325360
assertFalse ' .htaccess.prod was uploaded' "remote_file_exists '.htaccess.prod'"
326361
}
327362

363+
test_include_ftp_ignore_init() {
364+
cd $GIT_PROJECT_PATH
365+
echo 'htaccess' > .htaccess
366+
echo 'htaccess.prod' > .htaccess.prod
367+
echo '.htaccess:.htaccess.prod' > .git-ftp-include
368+
echo '.htaccess.prod' > .git-ftp-ignore
369+
git add .
370+
git commit -m 'htaccess setup' > /dev/null
371+
init=$($GIT_FTP_CMD init -u $GIT_FTP_USER -p $GIT_FTP_PASSWD $GIT_FTP_URL)
372+
assertTrue ' .htaccess was ignored' "remote_file_exists '.htaccess'"
373+
assertFalse ' .htaccess.prod was uploaded' "remote_file_exists '.htaccess.prod'"
374+
}
375+
376+
test_include_ftp_ignore_push() {
377+
cd $GIT_PROJECT_PATH
378+
init=$($GIT_FTP_CMD init -u $GIT_FTP_USER -p $GIT_FTP_PASSWD $GIT_FTP_URL)
379+
echo 'htaccess' > .htaccess
380+
echo 'htaccess.prod' > .htaccess.prod
381+
echo '.htaccess:.htaccess.prod' > .git-ftp-include
382+
echo '.htaccess.prod' > .git-ftp-ignore
383+
git add .
384+
git commit -m 'htaccess setup' > /dev/null
385+
push=$($GIT_FTP_CMD push -u $GIT_FTP_USER -p $GIT_FTP_PASSWD $GIT_FTP_URL)
386+
assertTrue ' .htaccess was ignored' "remote_file_exists '.htaccess'"
387+
assertFalse ' .htaccess.prod was uploaded' "remote_file_exists '.htaccess.prod'"
388+
}
389+
390+
# addresses issue #41
391+
test_include_similar() {
392+
cd $GIT_PROJECT_PATH
393+
echo 'unversioned' > foo.html
394+
echo '/foo.html' >> .gitignore
395+
echo 'foo.html:templates/foo.html' > .git-ftp-include
396+
mkdir templates
397+
echo 'new content' >> 'templates/foo.html'
398+
git add .
399+
git commit -m 'unversioned file foo.html should be uploaded with templates/foo.html' > /dev/null
400+
init=$($GIT_FTP_CMD init -u $GIT_FTP_USER -p $GIT_FTP_PASSWD $GIT_FTP_URL)
401+
assertTrue 'foo.html was not uploaded' "remote_file_exists 'foo.html'"
402+
assertTrue 'templates/foo.html was not uploaded' "remote_file_exists 'templates/foo.html'"
403+
}
404+
328405
test_hidden_file_only() {
329406
cd $GIT_PROJECT_PATH
330407
echo "test" > .htaccess

0 commit comments

Comments
 (0)