function _drush_config_merge_cleanup

7.x config.drush.inc _drush_config_merge_cleanup($merge_info)

Reset our state after a config-merge command

4 calls to _drush_config_merge_cleanup()
drush_config_merge in commands/core/config.drush.inc
drush_config_merge_rollback in commands/core/config.drush.inc
If drush_config_merge() exits with an error, then Drush will call the rollback function, so that we can clean up. We call the cleanup function explicitly if we exit with no error.
_drush_cm_merge_to_original_branch in commands/core/config.drush.inc
_drush_config_merge_action_abandon in commands/core/config.drush.inc
If the user wants to abandon the work of their merge, then clean up our temporary branches and return TRUE to cause the calling function to exit without committing.

File

commands/core/config.drush.inc, line 1232
Provides Configuration Management commands.

Code

function _drush_config_merge_cleanup($merge_info) {
  if (!empty($merge_info) && !empty($merge_info['configuration_path'])) {
    $configuration_path = $merge_info['configuration_path'];
    // If we are in the middle of a rebase, we must abort, or
    // git will remember this state for a long time (that is,
    // you can switch away from this branch and come back later,
    // and you'll still be in a "rebasing" state.)
    drush_shell_cd_and_exec($configuration_path, 'git rebase --abort');
    // Violently delete any untracked files in the configuration path
    // without prompting.  This isn't as dangerous as it sounds;
    // drush config-merge refuses to run if you have untracked files
    // here, and you can get anything that Drush config-merge put here
    // via `drush cex` (or just run config-merge again).
    drush_shell_cd_and_exec($configuration_path, 'git clean -d -f .');
    // Switch back to the branch we started on.
    $result = drush_shell_cd_and_exec($configuration_path, 'git checkout %s', $merge_info['original-branch']);
    if (!$result) {
      drush_log(dt("Could not return to original branch !branch", array('!branch' => $merge_info['original-branch'])), 'warning');
    }
    // Delete our temporary branches
    if ($merge_info['autodelete-live-config']) {
      drush_shell_cd_and_exec($configuration_path, 'git branch -D %s 2>/dev/null', $merge_info['live-config']);
    }
    if ($merge_info['autodelete-dev-config']) {
      drush_shell_cd_and_exec($configuration_path, 'git branch -D %s 2>/dev/null', $merge_info['dev-config']);
    }
  }
}