Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep gitignore & gitattributes on upgrade/rename #162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 28 additions & 4 deletions vcsh
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,34 @@ upgrade() {
elif [ ! "x$VCSH_WORKTREE" = 'xrelative' ]; then
git config core.worktree "$VCSH_BASE"
fi
[ ! "x$VCSH_GITIGNORE" = 'xnone' ] && git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME"
[ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && git config core.attributesfile ".gitattributes.d/$VCSH_REPO_NAME"
git config vcsh.vcsh 'true'
use
if [ ! "x$VCSH_GITIGNORE" = 'xnone' ]; then
old_gitignore_file=$(git config core.excludesfile)
git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME"
if [ ! -z "$old_gitignore_file" ] && [ ! "$old_gitignore_file" = ".gitignore.d/$VCSH_REPO_NAME" ] && [ ! "$old_gitignore_file" = "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ]; then
if [ -e "$VCSH_BASE/$old_gitignore_file" ]; then
mv "$VCSH_BASE/$old_gitignore_file" "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" || error "could not rename .gitignore.d file from $old_gitignore_file"
elif [ -e "$old_gitignore_file" ]; then
mv $old_gitignore_file "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" || error "could not rename .gitignore.d file from $old_gitignore_file"
else
debug "no old gitignore file to rename"
fi
fi
fi
if [ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ]; then
old_gitattributes_file=$(git config core.attributesfile)
git config core.attributesfile ".gitattributes.d/$VCSH_REPO_NAME"
if [ ! -z "$old_gitattributes_file" ] && [ ! "$old_gitattributes_file" = ".gitattributes.d/$VCSH_REPO_NAME" ] && [ ! "$old_gitattributes_file" = "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" ]; then
if [ -e "$VCSH_BASE/$old_gitattributes_file" ]; then
mv "$VCSH_BASE/$old_gitattributes_file" "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" || error "could not rename .gitattributes.d file from $old_gitattributes_file"
elif [ -e "$old_gitattributes_file" ]; then
mv $old_gitattributes_file "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" || error "could not rename .gitattributes.d file from $old_gitattributes_file"
else
debug "no old gitattributes file to rename"
fi
fi
fi
git config vcsh.vcsh 'true'
[ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME"
[ -e "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME"
hook post-upgrade
Expand Down Expand Up @@ -502,7 +526,7 @@ case $VCSH_COMMAND in
versio|versi|vers|ver|ve) VCSH_COMMAND=version;;
which|whi|wh) VCSH_COMMAND=which;;
write|writ|wri|wr) VCSH_COMMAND=write-gitignore;;
esac
esac

if [ x"$VCSH_COMMAND" = x'clone' ]; then
VCSH_BRANCH=
Expand Down