Skip to content
Snippets Groups Projects
Commit b1512d6c authored by Raphaël Gomès's avatar Raphaël Gomès
Browse files

Add script to generate a tarball of empty ignored files from a list

It effectively replicates the ignored files structure without much of its size
parent d95fe294
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
set -euo pipefail
if [[ $# -lt 2 ]]; then
echo 'usage: create-tarball-of-ignored NAME IGNORED_FILES '
echo ''
echo 'NAME is the name of the tarball'
echo 'IGNORED_FILES is a file containing `\n` delimited filenames'
echo ''
echo 'examples:'
echo ' create-tarball-of-ignored mercurial-ignored.tar ignored-files.txt'
exit 64
fi
initial_wd="$(pwd)"
root="$(realpath $(dirname $0) | tr -d '\n')"
echo "${root}"
name="$1"
shift
ignored_files="$1"
temp_workdir=/tmp/tarball-of-ignored-${name}-$RANDOM-workdir
rm -rf $temp_workdir
function finish {
cd "${initial_wd}"
rm -rf "$temp_workdir"
}
trap finish EXIT
echo "Generating empty ignored files"
mkdir -p "${temp_workdir}"
cd "${temp_workdir}"
while IFS="" read -r file || [[ -n "$file" ]]
do
mkdir -p "${file}" && touch "${file}"
done < ${ignored_files}
echo "Creating tarball"
tar cf "${initial_wd}/${name}" .
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment