0

When building Features, i find it useful to keep a 'backup' of the full configuration and commit it to version control.

If something breaks when i package a feature after i test how it works by doing a full re-install of the profile that brings together the feature modules, i can restore things i missed from the configuration export.

Unfortunately, every site install produces different UUIDs in every configuration file, so i cannot use a diff to determine if there are missing or unexpected changes in the site-install version of the configuration i packaged up. Drush does not have an export option to strip UUIDs on export.

In the past we used a script to delete all the UUID lines, but not being built into Drush, it was Python or Bash i think, it was awkward to use. But if i find it i'll post it.

How can i get a clean diff of changes that filters out the noise of the UUID changes?

3
  • Meant to mention, related but not the same as my goals here, drupal.stackexchange.com/questions/177139/… – mlncn Jul 24 '19 at 0:35
  • FYI: Since v8.6.0 there is now an explicit flag drush site:install --existing-config, which ignores the existing/mismatching UUIDs. This way you can an existing foreign site, without the content. – Hudri Jul 24 '19 at 12:49
  • @Hudri yep, well aware of it, and we were doing the same thing by some trickery in custom profiles for regular sitebuilding even before drupal.org/project/config_installer came along. The use case here is quite different: building Features, so repeatedly re-installing normally (not from the exported config), but wanting to export the config and compare exports as a check on our Feature packaging skills. Would still really prefer just a drush config export command that would skip the UUIDs :-/ – mlncn Jul 26 '19 at 13:32
0

The use case in question here is for building features; the config/sync directory is never used to import, but it can be used to check if the result of a site install is about what we expect (and to copy wanted files or changes we wanted to keep, and missed, from a saved version).

The meaningless UUID changes in every file, however, make it impossible to find that information in all the noise.

Here is a workaround that presumes you are using Git for version control, exporting configuration and committing it, then running a site install, and re-exporting the configuration (but not yet committing it):

git diff -G '^[^u]*([^u][^i][^d][^:]).*'

will show only files with non-uuid changes. If there's a change to a uuid other than the one for the configuration as a whole (that is, indented under some other part of the configuration), that will be shown.

Super unsure about the regex in this but it's not had a false negative or positive yet.

Here's what i have in my .bashrc to make this easier to use:

# Diff that ignores config files whose only change is the UUID (ignores lines
# starting with 'uuid:' and probably other stuff but it's solid so far.)
alias gdu="git diff -G '^[^u]*([^u][^i][^d][^:]).*'"

Took me forever to come up with this workaround; hope it helps others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.