From 38c9052046ff68783f3470d82ec91d15533f5e5f Mon Sep 17 00:00:00 2001 From: Stephen Augustus Date: Sun, 1 Mar 2020 04:52:42 -0500 Subject: [PATCH 1/3] lib: Add git status/show to gitlib::push_master Signed-off-by: Stephen Augustus --- lib/gitlib.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/gitlib.sh b/lib/gitlib.sh index 9cd506339fe..653d7145d6b 100644 --- a/lib/gitlib.sh +++ b/lib/gitlib.sh @@ -280,10 +280,12 @@ gitlib::push_master () { logecho -n "Checkout master branch to push objects: " logrun -s git checkout master || return 1 + logrun -v git status -s || return 1 + logrun -v git show || return 1 logecho -n "Rebase master branch: " - logrun git fetch origin || return 1 - logrun -s git rebase origin/master || return 1 + logrun -v git fetch origin || return 1 + logrun -s -v git rebase origin/master || return 1 logecho -n "Pushing$dryrun_flag master branch: " logrun -s git push$dryrun_flag origin master || return 1 } From 9b1fcf863e15991d4d36cdd2772d1844db98186d Mon Sep 17 00:00:00 2001 From: Stephen Augustus Date: Sun, 1 Mar 2020 14:46:46 -0500 Subject: [PATCH 2/3] anago: Add repo state check after release notes generation Signed-off-by: Stephen Augustus --- anago | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/anago b/anago index 735b5d976ea..1b4d7c20ec4 100755 --- a/anago +++ b/anago @@ -405,6 +405,8 @@ check_prerequisites () { PROGSTEP[generate_release_notes]="GENERATE RELEASE NOTES" generate_release_notes () { local release_tars=$TREE_ROOT/_output-$RELEASE_VERSION_PRIME/release-tars + local git_status_output + local repo_state logrun -v krel changelog \ --repo "$TREE_ROOT" \ @@ -414,6 +416,16 @@ generate_release_notes () { --html-file "$RELEASE_NOTES_HTML" \ --bucket="$RELEASE_BUCKET" \ || return 1 + + git_status_output=$(git status -s) + repo_state=$([[ -z $git_status_output ]] || echo "dirty") + + if [[ $repo_state == "dirty" ]]; then + logecho "Repo state was dirty after generating release notes. Cannot continue." + logecho "'git status -s' output:" + logecho "$git_status_output" + return 1 + fi } ############################################################################## From 7e4a3cec58d042b2e3a8503ebaed39d7ca23a81c Mon Sep 17 00:00:00 2001 From: Stephen Augustus Date: Sun, 1 Mar 2020 17:42:48 -0500 Subject: [PATCH 3/3] [krel] changelog: Include CHANGELOG/README.md in master commit logic Signed-off-by: Stephen Augustus --- cmd/krel/cmd/changelog.go | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/cmd/krel/cmd/changelog.go b/cmd/krel/cmd/changelog.go index fd2085cc044..494d5abf0c8 100644 --- a/cmd/krel/cmd/changelog.go +++ b/cmd/krel/cmd/changelog.go @@ -309,6 +309,10 @@ func htmlChangelogFilename(tag semver.Version) string { return changelogFilename(tag, "html") } +func markdownChangelogReadme() string { + return filepath.Join(repoChangelogDir, "README.md") +} + func markdownChangelogFilename(tag semver.Version) string { return filepath.Join(repoChangelogDir, changelogFilename(tag, "md")) } @@ -398,15 +402,24 @@ func lookupRemoteReleaseNotes(branch string) (string, error) { func commitChanges(repo *git.Repo, branch string, tag semver.Version) error { // Master branch modifications - filename := markdownChangelogFilename(tag) - logrus.Infof("Adding %s to repository", filename) - if err := repo.Add(filename); err != nil { - return errors.Wrapf(err, "trying to add file %s to repository", filename) + releaseChangelog := markdownChangelogFilename(tag) + changelogReadme := markdownChangelogReadme() + + changelogFiles := []string{ + releaseChangelog, + changelogReadme, + } + + for _, filename := range changelogFiles { + logrus.Infof("Adding %s to repository", filename) + if err := repo.Add(filename); err != nil { + return errors.Wrapf(err, "trying to add file %s to repository", filename) + } } logrus.Info("Committing changes to master branch in repository") if err := repo.Commit(fmt.Sprintf( - "Add %s for %s", filename, util.SemverToTagString(tag), + "CHANGELOG: Update directory for %s release", util.SemverToTagString(tag), )); err != nil { return errors.Wrap(err, "committing changes into repository") } @@ -423,13 +436,13 @@ func commitChanges(repo *git.Repo, branch string, tag semver.Version) error { } logrus.Info("Checking out changelog from master branch") - if err := repo.Checkout(git.Master, filename); err != nil { - return errors.Wrap(err, "checking out master branch changelog") + if err := repo.Checkout(git.Master, releaseChangelog); err != nil { + return errors.Wrap(err, "unable to check out master branch changelog") } logrus.Info("Committing changes to release branch in repository") if err := repo.Commit(fmt.Sprintf( - "Update %s for %s", filename, util.SemverToTagString(tag), + "Update %s for %s", releaseChangelog, util.SemverToTagString(tag), )); err != nil { return errors.Wrap(err, "committing changes into repository") }