From 19fb9d05190d9c3d04e804cc2ac299bc771220f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABlG?= Date: Mon, 9 Nov 2015 15:14:24 +0100 Subject: [PATCH 1/2] Fixed 'Can only flip STRING and INTEGER values! output.inc:184' --- config_extra.drush.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_extra.drush.inc b/config_extra.drush.inc index b86c483..cd8d124 100644 --- a/config_extra.drush.inc +++ b/config_extra.drush.inc @@ -282,7 +282,7 @@ function _drush_cme_get_initial_vcs_state(&$merge_info) { } $uncommitted_changes = drush_shell_exec_output(); if (!empty($uncommitted_changes)) { - return drush_set_error('DRUSH_CONFIG_MERGE_UNCOMMITTED_CHANGES', dt("Working set has uncommitted changes; please commit or discard them before merging. `git stash` before `drush config-merge`, and `git stash pop` afterwards can be useful here.\n\n!changes", array('!changes' => $uncommitted_changes))); + return drush_set_error('DRUSH_CONFIG_MERGE_UNCOMMITTED_CHANGES', dt("Working set has uncommitted changes; please commit or discard them before merging. `git stash` before `drush config-merge`, and `git stash pop` afterwards can be useful here.\n\n!changes", array('!changes' => implode('\n', $uncommitted_changes)))); } } From 1441e413d22fe91d76f0d38195697685c1e21ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABlG?= Date: Tue, 10 Nov 2015 17:27:26 +0100 Subject: [PATCH 2/2] Fixed lost commits when config-export changed nothing --- config_extra.drush.inc | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/config_extra.drush.inc b/config_extra.drush.inc index cd8d124..eeb1bfa 100644 --- a/config_extra.drush.inc +++ b/config_extra.drush.inc @@ -209,14 +209,20 @@ function drush_config_extra_config_merge($alias = '', $config_label = 'sync') { return FALSE; } - // Check to see if the export changed any files. If it did not, then - // skip the merge, and process only the config pulled in from the other site. - // TODO: This needs to be a diff against the base commit. In 'git' mode, - // we probably want to just skip this test and always merge. Maybe always do this? + // Check to see if the export (or previous ones) changed any files. If it did + // not, then skip the merge, and process only the config pulled in from the + // site. + $configuration_path = _drush_cme_get_configuration_path($merge_info); - $result = drush_shell_cd_and_exec($configuration_path, 'git status --porcelain .'); + // This is needed because diff-tree does not take untracked files into account. + $result = drush_shell_cd_and_exec($configuration_path, 'git add -A .'); if (!$result) { - return drush_set_error('DRUSH_CONFIG_MERGE_FAILURE', dt("`git status` failed.")); + return drush_set_error('DRUSH_CONFIG_MERGE_FAILURE', dt("`git add -A` failed.")); + } + + $result = drush_shell_cd_and_exec($configuration_path, 'git diff-tree --no-commit-id --name-only -r HEAD %s .', $merge_info['merge-base']); + if (!$result) { + return drush_set_error('DRUSH_CONFIG_EXPORT_FAILURE', dt("`git diff-tree` failed.")); } $changed_configuration_files = drush_shell_exec_output(); if (empty($changed_configuration_files)) { @@ -527,12 +533,21 @@ function _drush_cme_merge_local_and_remote_configurations(&$merge_info) { if (!$result) { return drush_set_error('DRUSH_CONFIG_MERGE_FAILURE', dt("`git add -A` failed.")); } - // Note that this commit will be `merge --squash`-ed away. We'll put in - // a descriptive message to help users understand where it came from, if - // they end up with dirty branches after an aborted run. - $result = drush_shell_cd_and_exec($configuration_path, 'git commit -m %s', 'Drush config-merge exported configuration from ' . $merge_info['dev-site'] . ' ' . $merge_info['message']); + // Commit only if there's something to commit. + $result = drush_shell_cd_and_exec($configuration_path, 'git status --porcelain .'); + if (!$result) { - return drush_set_error('DRUSH_CONFIG_MERGE_FAILURE', dt("`git commit` failed.")); + return drush_set_error('DRUSH_CONFIG_MERGE_FAILURE', dt("`git status` failed.")); + } + $uncommitted_changes = drush_shell_exec_output(); + if (!empty($uncommitted_changes)) { + // Note that this commit will be `merge --squash`-ed away. We'll put in + // a descriptive message to help users understand where it came from, if + // they end up with dirty branches after an aborted run. + $result = drush_shell_cd_and_exec($configuration_path, 'git commit -m %s', 'Drush config-merge exported configuration from ' . $merge_info['dev-site'] . ' ' . $merge_info['message']); + if (!$result) { + return drush_set_error('DRUSH_CONFIG_MERGE_FAILURE', dt("`git commit` failed.")); + } } // git checkout live-config && git rebase dev-config.