/** * Ensures the fetching of notes is configured for the remote. * * @param string $remote */ public function ensureNotesFetching($remote) { $fetches = StringUtil::splitLines($this->getGitConfig('remote.' . $remote . '.fetch', 'local', true)); if (!in_array('+refs/notes/*:refs/notes/*', $fetches, true)) { $this->getHelperSet()->get('gush_style')->note(sprintf('Set fetching of notes for remote "%s".', $remote)); $this->processHelper->runCommand(['git', 'config', '--add', '--local', 'remote.' . $remote . '.fetch', '+refs/notes/*:refs/notes/*']); } }
/** * @param string $base * @param string $branchName * @param bool $ignoreMultipleAuthors Ignore there are multiple authors (ake force) * * @throws WorkingTreeIsNotReady * @throws CannotSquashMultipleAuthors */ public function squashCommits($base, $branchName, $ignoreMultipleAuthors = false) { $this->guardWorkingTreeReady(); $this->stashBranchName(); $this->checkout($branchName); // Check if there are multiple authors, we only use the e-mail address // As the name could have changed (eg. typo's and accents) if (!$ignoreMultipleAuthors) { $authors = array_unique(StringUtil::splitLines($this->processHelper->runCommand(['git', '--no-pager', 'log', '--oneline', '--no-color', '--format=%ae', $base . '..' . $branchName]))); if (count($authors) > 1) { throw new CannotSquashMultipleAuthors(); } } // Get commits only in the branch but not in base (in reverse order) // we can't use --max-count here because that is applied before the reversing! // // using git-log works better then finding the fork-point with git-merge-base // because this protects against edge cases were there is no valid fork-point $firstCommitHash = StringUtil::splitLines($this->processHelper->runCommand(['git', '--no-pager', 'log', '--oneline', '--no-color', '--format=%H', '--reverse', $base . '..' . $branchName]))[0]; // 0=author anything higher then 0 is the full body $commitData = StringUtil::splitLines($this->processHelper->runCommand(['git', '--no-pager', 'show', '--format=%an <%ae>%n%s%n%n%b', '--no-color', '--no-patch', $firstCommitHash])); $author = array_shift($commitData); $message = implode("\n", $commitData); $this->reset($base); $this->commit($message, ['a', '-author' => $author]); }