mirror of
https://github.com/TheLocehiliosan/yadm
synced 2024-10-27 20:34:27 +00:00
Merge pull request #26 from cnaj/master
This commit is contained in:
commit
fe0ddd4c1a
58
yadm
58
yadm
@ -33,6 +33,9 @@ GPG_PROGRAM="gpg"
|
|||||||
GIT_PROGRAM="git"
|
GIT_PROGRAM="git"
|
||||||
LS_PROGRAM="/bin/ls"
|
LS_PROGRAM="/bin/ls"
|
||||||
|
|
||||||
|
#; flag causing path translations with cygpath
|
||||||
|
USE_CYGPATH=0
|
||||||
|
|
||||||
#; flag when something may have changes (which prompts auto actions to be performed)
|
#; flag when something may have changes (which prompts auto actions to be performed)
|
||||||
CHANGES_POSSIBLE=0
|
CHANGES_POSSIBLE=0
|
||||||
|
|
||||||
@ -113,7 +116,7 @@ function alt() {
|
|||||||
match="^(.+)##($match_system|$match_system.$match_host|$match_system.$match_host.$match_user|())$"
|
match="^(.+)##($match_system|$match_system.$match_host|$match_system.$match_host.$match_user|())$"
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
#; process relative to YADM_WORK
|
||||||
YADM_WORK=$("$GIT_PROGRAM" config core.worktree)
|
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
||||||
cd "$YADM_WORK" || {
|
cd "$YADM_WORK" || {
|
||||||
debug "Alternates not processed, unable to cd to $YADM_WORK"
|
debug "Alternates not processed, unable to cd to $YADM_WORK"
|
||||||
return
|
return
|
||||||
@ -201,7 +204,7 @@ function config() {
|
|||||||
echo TODO: Print help about available yadm configurations
|
echo TODO: Print help about available yadm configurations
|
||||||
else
|
else
|
||||||
#; operate on the yadm configuration file
|
#; operate on the yadm configuration file
|
||||||
git config --file="$YADM_CONFIG" "$@"
|
git config --file="$(mixed_path "$YADM_CONFIG")" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -211,7 +214,7 @@ function decrypt() {
|
|||||||
require_gpg
|
require_gpg
|
||||||
require_archive
|
require_archive
|
||||||
|
|
||||||
YADM_WORK=$("$GIT_PROGRAM" config core.worktree)
|
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
||||||
|
|
||||||
if [ "$DO_LIST" = "YES" ] ; then
|
if [ "$DO_LIST" = "YES" ] ; then
|
||||||
tar_option="t"
|
tar_option="t"
|
||||||
@ -237,7 +240,7 @@ function encrypt() {
|
|||||||
require_ls
|
require_ls
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
#; process relative to YADM_WORK
|
||||||
YADM_WORK=$("$GIT_PROGRAM" config core.worktree)
|
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
||||||
cd "$YADM_WORK" || {
|
cd "$YADM_WORK" || {
|
||||||
debug "Encryption not processed, unable to cd to $YADM_WORK"
|
debug "Encryption not processed, unable to cd to $YADM_WORK"
|
||||||
return
|
return
|
||||||
@ -274,14 +277,14 @@ function encrypt() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#; offer to add YADM_ARCHIVE if untracked
|
#; offer to add YADM_ARCHIVE if untracked
|
||||||
archive_status=$("$GIT_PROGRAM" status --porcelain -uall "$YADM_ARCHIVE" 2>/dev/null)
|
archive_status=$("$GIT_PROGRAM" status --porcelain -uall "$(mixed_path "$YADM_ARCHIVE")" 2>/dev/null)
|
||||||
archive_regex="^\?\?"
|
archive_regex="^\?\?"
|
||||||
if [[ $archive_status =~ $archive_regex ]] ; then
|
if [[ $archive_status =~ $archive_regex ]] ; then
|
||||||
echo "It appears that $YADM_ARCHIVE is not tracked by yadm's repository."
|
echo "It appears that $YADM_ARCHIVE is not tracked by yadm's repository."
|
||||||
echo "Would you like to add it now? (y/n)"
|
echo "Would you like to add it now? (y/n)"
|
||||||
read -r answer
|
read -r answer
|
||||||
if [[ $answer =~ ^[yY]$ ]] ; then
|
if [[ $answer =~ ^[yY]$ ]] ; then
|
||||||
"$GIT_PROGRAM" add "$YADM_ARCHIVE"
|
"$GIT_PROGRAM" add "$(mixed_path "$YADM_ARCHIVE")"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -354,7 +357,7 @@ function init() {
|
|||||||
|
|
||||||
#; init a new bare repo
|
#; init a new bare repo
|
||||||
debug "Init new repo"
|
debug "Init new repo"
|
||||||
"$GIT_PROGRAM" init --shared=0600 --bare "$YADM_REPO" "$@"
|
"$GIT_PROGRAM" init --shared=0600 --bare "$(mixed_path "$YADM_REPO")" "$@"
|
||||||
configure_repo
|
configure_repo
|
||||||
|
|
||||||
CHANGES_POSSIBLE=1
|
CHANGES_POSSIBLE=1
|
||||||
@ -367,7 +370,7 @@ function list() {
|
|||||||
|
|
||||||
#; process relative to YADM_WORK when --all is specified
|
#; process relative to YADM_WORK when --all is specified
|
||||||
if [ -n "$LIST_ALL" ] ; then
|
if [ -n "$LIST_ALL" ] ; then
|
||||||
YADM_WORK=$("$GIT_PROGRAM" config core.worktree)
|
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
||||||
cd "$YADM_WORK" || {
|
cd "$YADM_WORK" || {
|
||||||
debug "List not processed, unable to cd to $YADM_WORK"
|
debug "List not processed, unable to cd to $YADM_WORK"
|
||||||
return
|
return
|
||||||
@ -386,7 +389,7 @@ function perms() {
|
|||||||
#; TODO: prevent repeats in the files changed
|
#; TODO: prevent repeats in the files changed
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
#; process relative to YADM_WORK
|
||||||
YADM_WORK=$("$GIT_PROGRAM" config core.worktree)
|
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
||||||
cd "$YADM_WORK" || {
|
cd "$YADM_WORK" || {
|
||||||
debug "Perms not processed, unable to cd to $YADM_WORK"
|
debug "Perms not processed, unable to cd to $YADM_WORK"
|
||||||
return
|
return
|
||||||
@ -507,7 +510,8 @@ function configure_paths() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#; use the yadm repo for all git operations
|
#; use the yadm repo for all git operations
|
||||||
export GIT_DIR="$YADM_REPO"
|
GIT_DIR=$(mixed_path "$YADM_REPO")
|
||||||
|
export GIT_DIR
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,7 +523,7 @@ function configure_repo() {
|
|||||||
"$GIT_PROGRAM" config core.bare 'false'
|
"$GIT_PROGRAM" config core.bare 'false'
|
||||||
|
|
||||||
#; set the worktree for the yadm repo
|
#; set the worktree for the yadm repo
|
||||||
"$GIT_PROGRAM" config core.worktree "$YADM_WORK"
|
"$GIT_PROGRAM" config core.worktree "$(mixed_path "$YADM_WORK")"
|
||||||
|
|
||||||
#; by default, do not show untracked files and directories
|
#; by default, do not show untracked files and directories
|
||||||
"$GIT_PROGRAM" config status.showUntrackedFiles no
|
"$GIT_PROGRAM" config status.showUntrackedFiles no
|
||||||
@ -615,10 +619,42 @@ function require_ls() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#; ****** Directory tranlations ******
|
||||||
|
|
||||||
|
function test_cygwin() {
|
||||||
|
case "$(uname -s)" in
|
||||||
|
CYGWIN*)
|
||||||
|
git_version=$(git --version 2>/dev/null)
|
||||||
|
if [[ "$git_version" =~ windows ]] ; then
|
||||||
|
USE_CYGPATH=1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
function unix_path() {
|
||||||
|
#; for paths used by bash/yadm
|
||||||
|
if [ "$USE_CYGPATH" = "1" ] ; then
|
||||||
|
cygpath -u "$1"
|
||||||
|
else
|
||||||
|
echo "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function mixed_path() {
|
||||||
|
#; for paths used by Git
|
||||||
|
if [ "$USE_CYGPATH" = "1" ] ; then
|
||||||
|
cygpath -m "$1"
|
||||||
|
else
|
||||||
|
echo "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#; ****** Main processing (when not unit testing) ******
|
#; ****** Main processing (when not unit testing) ******
|
||||||
|
|
||||||
if [ "$YADM_TEST" != 1 ] ; then
|
if [ "$YADM_TEST" != 1 ] ; then
|
||||||
process_global_args "$@"
|
process_global_args "$@"
|
||||||
|
test_cygwin
|
||||||
configure_paths
|
configure_paths
|
||||||
main "${MAIN_ARGS[@]}"
|
main "${MAIN_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user