Skip to content

Instantly share code, notes, and snippets.

@jzahedieh
Last active August 29, 2015 14:07
Show Gist options
  • Save jzahedieh/b57b03441181f65467a2 to your computer and use it in GitHub Desktop.
Save jzahedieh/b57b03441181f65467a2 to your computer and use it in GitHub Desktop.
Base script that adds svn:ignore from a .gitignore file
#!/bin/bash
FileArray=()
while read line
do
# starts and ends with a slash (folder)
if [[ ${line} == /* ]] && [[ ${line} == */ ]]; then
path=${line#?} # strip first slash
echo "Processing Folder: ${path}"
# loop over all directories so we can make sure they are all added
# so that we can ignore the folders within them.
holder=''
for folder in $(echo ${path} | tr "/" "\n")
do
# append folder to the holder
holder+="${folder}/"
# suppress error as will try too add folder multiple times (not efficent but meh)
# -N flag only adds folder no content (required to ignore)
svn add -N ${holder} 2>/dev/null
done
# ignore our folders content
# we can only do the content as it is a single rule, otherwise you need multiple rules
svn propset svn:ignore '*' ${path}
fi
# starts with a slash but does not end with a slash (file)
if [[ ${line} == /* ]] && [[ ${line} != */ ]]; then
path=${line#?} # strip first slash
echo "Processing File: ${line}"
holder=''
for folder in $(echo ${path} | tr "/" " ")
do
# append folder to the holder
holder+="${folder}/"
done
# somehow need to group all files by folder
# make sure that folder is added with -N
# propset the list of files in that folder that need to be ignored
# or we attempt to append an item into propedit,.
# damn you Branko and Brane why no --append in 05 (http://marc.info/?t=110749423200002&r=1&w=2)
fi
done < .gitignore
# damnit, just use propset manually for these files?
svn propset svn:ignore ".htaccess
.htaccess.sample
LICENSE.html
LICENSE.txt
LICENSE_AFL.txt
LICENSE_EE.html
LICENSE_EE.txt
RELEASE_NOTES.txt
api.php
cron.php
cron.sh
favicon.ico
get.php
index.php
index.php.sample
install.php
mage
php.ini.sample" .
svn propset svn:ignore "blank.html
index.php
spacer.gif" js
svn propset svn:ignore ".htaccess
Mage.php" app
svn add -N app/etc
svn propset svn:ignore "config.xml
enterprise.xml
local.xml
local.xml.additional
local.xml.template" app/etc
svn add -N app/etc/modules
svn propset svn:ignore "Cm_RedisSession.xml
Enterprise_*.xml
Mage_*.xml
Phoenix_Moneybookers.xml" app/etc/modules
# revert all added folders and files since it's all bs
# removes ignores on files (WTF)
# - this means we have to have empty folders checked in to ignore??
#svn revert -R .
# This has the same problem, removing files but on a loop level
# Loop 20 times as child has to be called before parent (lazy)
#for i in $(seq 1 1 20)
#do
# for status in $(svn status -q); do
# echo ${status}
# # if it is a directory
# if [ -d ${status} ]; then
# svn revert ${status}
# fi
# done
#done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment