From 9f3c7323c0db2fea63e98c6af96d1147479c7442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20H=C3=BCbelbauer?= Date: Sun, 31 Dec 2017 12:47:42 +0100 Subject: [PATCH] Clean up README.md and tasks --- Excel.xlsx.git/_rels/.rels | 8 ++++-- Excel.xlsx.git/xl/_rels/workbook.xml.rels | 9 +++++-- README.md | 25 ++++++++----------- Word.docx.git/_rels/.rels | 8 ++++-- Word.docx.git/word/_rels/document.xml.rels | 10 ++++++-- ...re-commit.ps1 => version-office-files.ps1} | 2 +- doc/tasks.md | 4 +-- 7 files changed, 39 insertions(+), 27 deletions(-) rename cmd/{pre-commit.ps1 => version-office-files.ps1} (89%) diff --git a/Excel.xlsx.git/_rels/.rels b/Excel.xlsx.git/_rels/.rels index 3030df4..bdc6ae3 100644 --- a/Excel.xlsx.git/_rels/.rels +++ b/Excel.xlsx.git/_rels/.rels @@ -1,2 +1,6 @@ - - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/Excel.xlsx.git/xl/_rels/workbook.xml.rels b/Excel.xlsx.git/xl/_rels/workbook.xml.rels index 8cd5f3f..7ac2bad 100644 --- a/Excel.xlsx.git/xl/_rels/workbook.xml.rels +++ b/Excel.xlsx.git/xl/_rels/workbook.xml.rels @@ -1,2 +1,7 @@ - - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 9ff2dc0..0381b97 100644 --- a/README.md +++ b/README.md @@ -3,21 +3,18 @@ > An experiment in tracking versions of modern Office XML files in Git. Modern Office file formats are ZIP archives with XML files in them. -The ZIP archives are binary files so Git (GitHub, GitLab where diff cannot be configured) won't display a nice diff for them. -The XML files are not binary, so in order to display a diff for these, I unpack the ZIP files to directories that are tracked in Git. -Tracking generated files is pretty dumb, but so it tracking binary files and when forced to have, -it's not a leap to have the other if it bring something useful to the table. +The ZIP archives are binary files so Git (and furthemore GitHub, GitLab where diff cannot be tweaked) won't display a nice diff for them. +The XML files are not binary, so in order to display a diff for these, this unpacks the ZIP files to directories that are tracked in Git. +Tracking generated files is pretty dumb, but so is tracking binary files and when forced to have one, +it's not a leap to have the other as well if it bring something useful to the table. -The way I achieve this is using a [Git pre-commit hook](https://git-scm.com/book/gr/v2/Customizing-Git-Git-Hooks). -The hook unpacks the ZIP file to a tracked directory, formats the XML files for nice diff and tracks the formatted files as well. - -I am using PowerShell because it can be used portably and trying to do this in Bash across native shells and MinGW -(which is horrible to work with in the default installation of Git for Windows, -because it lacks `mingw-get` to install dependecies like `7z` and is just generally horrible and terrible and stuff) -would be harder for me. +This is achieved using a PowerShell script which unpacks the ZIP file to a tracked directory, +formats the XML files for nice diff and tracks the formatted files as well. ## Running +Run `cmd/version-office-files.ps1` whenever you want to add a new version, additionally you can do that on each commit with a hook: + - Set up the pre-commit hook: ```sh @@ -29,18 +26,16 @@ code .git/hooks/pre-commit ```sh #!/usr/bin/env bash -powershell cmd/pre-commit.ps1 +powershell cmd/version-office-files.ps1 ``` -- Open the file and make some changes +- Open the files and make some changes - `open` on Unix - `start` on Windows - `git add *` - `git commit -m "Make some changes"` - See the commit diff for the Office changes -Or just make the changes and run the `cmd/pre-commit.ps1` script in PowerShell ISE. - ## Studying See `git log` and [development notes](doc/notes.md). diff --git a/Word.docx.git/_rels/.rels b/Word.docx.git/_rels/.rels index fdd8c4f..532e302 100644 --- a/Word.docx.git/_rels/.rels +++ b/Word.docx.git/_rels/.rels @@ -1,2 +1,6 @@ - - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/Word.docx.git/word/_rels/document.xml.rels b/Word.docx.git/word/_rels/document.xml.rels index 0079d06..df1aaec 100644 --- a/Word.docx.git/word/_rels/document.xml.rels +++ b/Word.docx.git/word/_rels/document.xml.rels @@ -1,2 +1,8 @@ - - \ No newline at end of file + + + + + + + + \ No newline at end of file diff --git a/cmd/pre-commit.ps1 b/cmd/version-office-files.ps1 similarity index 89% rename from cmd/pre-commit.ps1 rename to cmd/version-office-files.ps1 index 85ba7c9..bc5c19a 100644 --- a/cmd/pre-commit.ps1 +++ b/cmd/version-office-files.ps1 @@ -9,7 +9,7 @@ Get-ChildItem .\* -Include ("*.docx", "*.xlsx", "*.pptx") -Recurse | Remove-Item "$officePath.zip" # Format XML files for nice diff - Get-ChildItem "$officePath.git" -Filter *.xml -Recurse | + Get-ChildItem "$officePath.git" -Include ("*.xml", "*.rels") -Recurse | Foreach-Object { $xmlPath = $_.FullName Write-Output "Formatting $xmlPath" diff --git a/doc/tasks.md b/doc/tasks.md index 84aef01..981207b 100644 --- a/doc/tasks.md +++ b/doc/tasks.md @@ -2,7 +2,5 @@ > Planned development: -- Delete `$officeFile.git` directories without matching files where encountered -- Fix adding only XML files because there can also be non-XML files (thumbnails and others) which currently have to be added manually - - Do one `git add` on the whole `.git` directory instead - Experiment with generating `.txt` file within the `.git` directory with just text nodes extracted from XML for lossy text-only diff +- See why `PowerPoint.pptx.zip` sticks around when it should get deleted and why it does get deleted for other formats -- 2.18.1