Commit 9f3c7323 authored by Tomáš Hübelbauer's avatar Tomáš Hübelbauer

Clean up README.md and tasks

parent 8bbc2f04
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" />
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" />
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml" />
</Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/></Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml" />
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml" />
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml" />
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml" />
</Relationships>
\ No newline at end of file
......@@ -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).
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml" />
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml" />
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" />
</Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/><Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/></Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml" />
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml" />
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml" />
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml" />
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml" />
</Relationships>
\ No newline at end of file
......@@ -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"
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment