Skip to content

Commit

Permalink
update README to reflect new placeholder model
Browse files Browse the repository at this point in the history
  • Loading branch information
Katriel Friedman committed Apr 24, 2015
1 parent e15777d commit d6a5a3c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ xlsx-git provides hooks to convert .xlsx files into their XML format before comm
## Issues
- **NOT TESTED AND MAY WIPE OUT ALL YOUR FILES**.
- risk of conflicts with other files
- xlsx files don't actually appear in the repository

### Checkout restrictions
When you have .xlsx files in your repo, you won't be able to checkout other branches or commits because the post-checkout hook always leaves the .xlsx files in a "modified" state. This protects you against accidentally losing saved but not committed work in Excel. Before `checkout`, use `git stash` to get to a clean state by hiding away your Excel files.

## Installation and Use
1. Place pre-commit and post-commit in the .git/hooks/ directory of your repository.
2. Make sure they are executable (e.g., `chmod 755 *-commit`)

## Dependencies
I use Cygwin and the GNU tools that go with that. With Git Extensions or MinGW you may need some other basic commands, like dirname and basename. Some packages in particular:
* `bash` >= 4.0
* `xmllint`
I use Cygwin and the GNU tools that go with that. With Git Extensions or MinGW you may need some other basic commands, like dirname and basename. In addition:
* `zip` and `unzip`
2 changes: 2 additions & 0 deletions post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# the XML in the repository, not the zip file.
#
# companion to pre-commit-excel
# currently identical to post-commit

# -- config -- #
TMP_PREFIX='.~' # prefix XML directory--should NOT conflict with
Expand All @@ -16,6 +17,7 @@ echo "=== Post-checkout XLSX processing ===="

repack_xlsx () {
# re-zip the XML directory
rm "$1"
cd "${TMP_PREFIX}$1"
zip "../$1" -r *
cd ..
Expand Down
7 changes: 5 additions & 2 deletions pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ unpack_xlsx () {
# create a placeholder text file for the .xlsx file, which uniquely identifies
# it and prevents losing work on a checkout
replace_with_placeholder () {
sha1sum "$1" > "$1"
sha1sum "$1" | tee "$1" > /dev/null # hack for overwriting without temp file
}


Expand All @@ -56,11 +56,14 @@ for i in $(git diff --name-only --cached -- *.xlsx); do
cd "$dir"
unpack_xlsx "$file"
replace_with_placeholder "$file"
echo -n "Commit placeholder file: "
file "$file"
reformat_xmls "${TMP_PREFIX}$file"
cd -

# stage the XML files
# stage the XML files and the placeholder
git add "$dir/${TMP_PREFIX}$file"
git add "$dir/$file"
done

echo "=== End of pre-commit processing ==="
Expand Down

0 comments on commit d6a5a3c

Please sign in to comment.