Adds gdk diff-config command to preview config changes
What
Adds gdk diff-config
command to preview a diff of changes which will be made to gitlab/config/gitlab.yml
and other config files.
Why
I want to be able to see what changes will be made to gitlab.yml
before overwriting it. Especially when working on a feature which requires me to change things. Similarly I keep a line commented out in Procfile and don't want to unnecessarily reset that.
How
- Creates a temporary backup at file.unchanged
- Runs
Make
to update the config file - Runs
git diff --color --no-index file file.unchanged
- Restores file
After all files have been updated the Make
output is printed to stderr
, followed by the diff output to stdout
. This allows gdk diff-config | less
to show just the relevant output.
Works by creating a temporary blob with git hash-object -w
for each file, making changes, comparing and finally restoring the original file.
The comparison step works by using git mktree
to create a fake tree object for the config files, another after making changes, and using git diff old_tree new_tree
to compare the two.
Screenshot
After the following gdk diff-config
I can update a single file with make gitlab/config/database.yml
instead of overwriting my changes to two other files at the same time with gdk reconfigure
: