-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Idempotent operations for reading, checkout branch prior to writing #47
Conversation
…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>
Prevents env issues during CI. Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
@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; |
There was a problem hiding this comment.
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 👍
There was a problem hiding this 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 👍
string $repositoryDirectory | ||
): bool { | ||
$process = new Process(['git', 'show', $sourceBranch->name() . ':CHANGELOG.md'], $repositoryDirectory); | ||
$process->run(); |
There was a problem hiding this comment.
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.
Details fix for changelog operations. Signed-off-by: Matthew Weier O'Phinney <matthew@weierophinney.net>
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 ofgit 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 usinggit show {REF}:CHANGELOG.md
.This change was introduced toCreateReleaseTextViaKeepAChangelog
.Any operation that will write to the CHANGELOG.md now first uses
ChangelogExists
to test for the file, and then performs aCheckoutBranch
operation to ensure that the correct version is updated, and to ensure we push back to the correct branch. Specifically, I updatedCreateReleaseTextViaKeepAChangelog
to compose aCheckoutBranch
instance for use after determining changes can be made.This should resolve all remaining issues regarding updates to the changelog file.