Skip to content

Commit

Permalink
--uncommited and --unstaged options for testing new content.
Browse files Browse the repository at this point in the history
Push only uncommited or even unstaged files to your ftp server.
This may be usefull for testing new content befor commiting it
to a repository.
  • Loading branch information
steelman committed Aug 8, 2011
1 parent c530f6d commit e3d53ed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 24 additions & 2 deletions git-ftp
Expand Up @@ -58,6 +58,8 @@ declare -i FORCE=0
declare -i ENABLE_REMOTE_LCK=0
declare -i ACTIVE_MODE=0
declare -i USE_KEYCHAIN=0
declare -i UNSTAGED=0
declare -i UNCOMMITED=0

# ------------------------------------------------------------
# Constant Exit Error Codes
Expand Down Expand Up @@ -132,6 +134,8 @@ OPTIONS
-f, --force Force, does not ask questions
-n, --silent Silent
-v, --verbose Verbose
--uncommited Push uncommited files, both staged and not
--unstaged Push unstaged files, good for testing
--cacert <file> Use <file> as certificate for server authentication
--version Prints version
Expand Down Expand Up @@ -418,6 +422,7 @@ set_remote_protocol() {
}

set_deployed_sha1() {
local local_sha1=$(git log -n 1 --pretty=format:%H)
# Return if commit is set by user interaction using --commit
if [ -n "$DEPLOYED_SHA1" ]; then
return
Expand All @@ -427,12 +432,21 @@ set_deployed_sha1() {
DEPLOYED_SHA1="$(get_file_content $DEPLOYED_SHA1_FILE)"
check_exit_status "Could not get last commit. Network down? Wrong URL? Use 'git ftp init' for the inital push." $ERROR_DOWNLOAD
write_log "Last deployed SHA1 for $REMOTE_HOST/$REMOTE_PATH is $DEPLOYED_SHA1"
if [ $UNCOMMITED -ne 0 -o $UNSTAGED -ne 0 ]; then
if [ "$local_sha1" != "$DEPLOYED_SHA1" ]; then
print_error_and_die "Some commits haven't been deployed."
fi
fi
}

set_changed_files() {
# Get raw list of files
if [ $IGNORE_DEPLOYED -ne 0 ]; then
git ls-files -t > '.git-ftp-tmp'
elif [ $UNSTAGED -ne 0 ]; then
git diff --name-status 2>/dev/null > '.git-ftp-tmp'
elif [ $UNCOMMITED -ne 0 ]; then
git diff --name-status HEAD 2>/dev/null > '.git-ftp-tmp'
else
git diff --name-status $DEPLOYED_SHA1 2>/dev/null > '.git-ftp-tmp'
fi
Expand Down Expand Up @@ -635,14 +649,14 @@ action_init() {
action_push() {
check_git_version
check_is_git_project
check_is_dirty_repository
[ $UNCOMMITED -eq 0 -a $UNSTAGED -eq 0 ] && check_is_dirty_repository
set_remotes
lock
set_deployed_sha1
set_changed_files
remote_lock
handle_file_sync
upload_local_sha1
[ $UNCOMMITED -eq 0 -a $UNSTAGED -eq 0 ] && upload_local_sha1
release_remote_lock
release_lock
}
Expand Down Expand Up @@ -890,6 +904,14 @@ do
ACTIVE_MODE=1
write_log "Using active mode"
;;
--unstaged)
UNSTAGED=1
write_log "Pushing unstaged files"
;;
--uncommited)
UNCOMMITED=1
write_log "Pushing uncommited files"
;;
*)
# Pass thru anything that may be meant for fetch.
[ -n "$1" ] && URL=$1
Expand Down
4 changes: 4 additions & 0 deletions man/git-ftp.1.md
Expand Up @@ -89,6 +89,10 @@ Another advantage is Git-ftp only handles files which are tracked with [Git].
: Don't verify server certificate. BE CAREFUL!
`--cacert <file>`
: Use **FILE** as CA certificate store. Usefull when a server has got a self-signed certificate. The **FILE** is relative to the directory the command is invoked in. When a relative pathname is set in the git-ftp.cacert option (git-ftp.SCOPE.cacert is also available), it's relative to the top of the git repository.
`--uncommited`
: Push to a server files that are tracked and have been modified but not yet commited, both staged and not.
`--unstaged`
: Push to a server files that are tracked and have been modified but not yet added to the index.

# URL

Expand Down

0 comments on commit e3d53ed

Please sign in to comment.