Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idempotent operations for reading, checkout branch prior to writing #47

Merged
merged 6 commits into from
Aug 12, 2020

Conversation

weierophinney
Copy link
Member

@weierophinney weierophinney commented Aug 12, 2020

Q A
BC Break? No
Bug? Yes — #46

This patch does the following:

  • Adds the interface ChangelogExists, with one implementation, ChangelogExistsViaConsole. The functionality is intended to be used whenever we want to check for existence of a changelog on a given branch, and is idempotent (it uses the exit code of git show {REF}:CHANGELOG.md to determine existence).

  • Any operation that needs to check for existence of the changelog now composes an instance of ChangelogExists for that purpose.

  • Operations that only read the CHANGELOG.md now do so using git show {REF}:CHANGELOG.md.This change was introduced to CreateReleaseTextViaKeepAChangelog.

  • Any operation that will write to the CHANGELOG.md now first uses ChangelogExists to test for the file, and then performs a CheckoutBranch operation to ensure that the correct version is updated, and to ensure we push back to the correct branch. Specifically, I updated CreateReleaseTextViaKeepAChangelog to compose a CheckoutBranch instance for use after determining changes can be made.

This should resolve all remaining issues regarding updates to the changelog file.

…nch prior to doing work

We should test for the CHANGELOG.md file in the release branch in an
idempotent way; we can use the exit code of `git show
{REF}:CHANGELOG.md` for this.

When we want to change the changelog file, we need to switch to the
associated release branch first.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
Updates `CreateReleaseTextViaKeepAChangelog` to use `git show
{ref}:CHANGELOG.md` to to test for the existence of the file, as well as
to fetch its contents, making the operation idempotent.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
I was reproducing the same code a ton; time to extract it.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
…elog file on a branch

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney added Bug Something isn't working Review Needed labels Aug 12, 2020
@weierophinney weierophinney added this to the 1.2.2 milestone Aug 12, 2020
Prevents env issues during CI.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney
Copy link
Member Author

@Ocramius all yours to review. :)

Details fix for changelog operations.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
use Webmozart\Assert\Assert;

use function file_exists;
use function file_get_contents;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that these filesystem access operations went away from here 👍

Copy link
Member

@Ocramius Ocramius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matches discussions, improves state management too 👍

:shipit:

@Ocramius Ocramius self-assigned this Aug 12, 2020
@Ocramius Ocramius merged commit a048deb into laminas:1.2.x Aug 12, 2020
string $repositoryDirectory
): bool {
$process = new Process(['git', 'show', $sourceBranch->name() . ':CHANGELOG.md'], $repositoryDirectory);
$process->run();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very specifically not "mustRun()" here, as failure is an expected status.

weierophinney added a commit that referenced this pull request Aug 12, 2020
Details fix for changelog operations.

Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@weierophinney weierophinney deleted the hotfix/fix-changelog-operations branch August 13, 2020 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Review Needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants