From: Don Zickus <dzic...@redhat.com>

Currently all the magic to sync upstream with os-build and ark-patches
is done through scripts in redhat/scripts/ci and .gitlab-ci.yml.

Make this easier by enabling this routine through a redhat/Makefile.

This allows:
* gitlab-ci.yml and maintainer to use same script
* allows maintainer to run local test runs before committing
* developers to hack on things a little more easily

This change also adds the ability to 'git push' the changes.  This is
safe because os-build and ark-patches are considered 'protected'
branches meaning only the developers in the 'Maintainers' group can
push to those branches (which is a tiny group right now).

Because I can't atomically commit this change and the change to
kernel-ark-ci's gitlab-ci.yml file, I need this change to go in first.

Then I can modify the gitlab-ci.yml file.

Functionally, this change should be no different than what currently
runs today.
---
 redhat/Makefile                         | 22 ++++++++++++++++++++
 redhat/scripts/ci/ark-rebase-patches.sh | 16 ++++++++++++---
 redhat/scripts/ci/ark-update-configs.sh | 27 ++++++++++++++++++++++++-
 3 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/redhat/Makefile b/redhat/Makefile
index 7cdf9e3bd0bf..61dcc522fbc6 100644
--- a/redhat/Makefile
+++ b/redhat/Makefile
@@ -319,6 +319,28 @@ dist-release: dist-clean-sources
 dist-release-tag:
        @git tag -a -m "$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)" 
$(PACKAGE_NAME)-$(STAMP_VERSION)-$(PKGRELEASE)
 
+DIST_BRANCH ?= "os-build"
+dist-merge-upstream:
+       @if test -n "$(DIST_PUSH)" && test -z "$(shell git remote get-url 
gitlab 2>/dev/null)"; then \
+               echo -e "Please run 'git remote add gitlab <url>' to enable 
git-push.\n"; \
+               exit 1; \
+       fi
+       @if test "$(shell git branch --show-current)" != "$(DIST_BRANCH)"; then 
\
+               echo -e "Please checkout $(DIST_BRANCH) branch before 
merging.\n"; \
+               exit 1; \
+               fi;
+       @(shell git --no-optional-locks status -uno --porcelain 2>/dev/null || \
+               { echo -e "Dirty tree, please clean before merging.\n"; exit 1; 
})
+
+       @# If TAG is empty, script defaults to master:HEAD
+       @$(REDHAT)/scripts/ci/ark-rebase-patches.sh $(TAG) || exit 1
+       @$(REDHAT)/scripts/ci/ark-update-configs.sh $(TAG)
+
+dist-merge-upstream-push: DIST_PUSH="1"
+dist-merge-upstream-push: dist-merge-upstream
+
+
+
 .PHONY: dist-brew dist-koji
 dist-brew : BUILD_FLAGS ?= $(BREW_FLAGS) $(TEST_FLAGS)
 dist-koji : BUILD_FLAGS ?= $(KOJI_FLAGS) $(TEST_FLAGS)
diff --git a/redhat/scripts/ci/ark-rebase-patches.sh 
b/redhat/scripts/ci/ark-rebase-patches.sh
index 561a927d5946..ef2183ecc799 100755
--- a/redhat/scripts/ci/ark-rebase-patches.sh
+++ b/redhat/scripts/ci/ark-rebase-patches.sh
@@ -21,7 +21,7 @@
 set -e
 
 UPSTREAM_REF=${1:-master}
-PROJECT_ID=${2:-13604247}
+test -n "$PROJECT_ID" || PROJECT_ID="${2:-13604247}"
 
 ISSUE_TEMPLATE="During an automated rebase of ark-patches, commit %s failed to 
rebase.
 
@@ -98,7 +98,12 @@ else
 fi
 
 if $CLEAN_REBASE; then
-       printf "You can safely update ark-patches with 'git push -f <remote> 
ark-patches'\n"
+       if test -n "$DIST_PUSH"; then
+               echo "Pushing branch ark-patches to $(get remote get-url 
gitlab)"
+               git push -f gitlab ark-patches
+       else
+               printf "You can safely update ark-patches with 'git push -f 
<remote> ark-patches'\n"
+       fi
 else
        printf "Some patches could not be rebased, fix up ark-patches as 
necessary"
        printf " before pushing the branch."
@@ -108,5 +113,10 @@ fi
 if git tag -v "$UPSTREAM_REF" > /dev/null 2>&1; then
        printf "Creating branch \"ark/patches/%s\"\n" "$UPSTREAM_REF"
        git branch ark/patches/"$UPSTREAM_REF"
-       printf "Don't forget to run 'git push <remote> ark/patches/%s'\n" 
"$UPSTREAM_REF"
+       if test -n "$DIST_PUSH"; then
+               echo "Pushing branch ark/patches to $(get remote get-url 
gitlab)"
+               git push gitlab ark/patches/"$UPSTREAM_REF"
+       else
+               printf "Don't forget to run 'git push <remote> 
ark/patches/%s'\n" "$UPSTREAM_REF"
+       fi
 fi
diff --git a/redhat/scripts/ci/ark-update-configs.sh 
b/redhat/scripts/ci/ark-update-configs.sh
index 5fb13eaf60d6..22dcead23f88 100755
--- a/redhat/scripts/ci/ark-update-configs.sh
+++ b/redhat/scripts/ci/ark-update-configs.sh
@@ -19,7 +19,7 @@
 set -e
 
 UPSTREAM_REF=${1:-master}
-PROJECT_ID=${2:-13604247}
+test -n "$PROJECT_ID" || PROJECT_ID="${2:-13604247}"
 
 ISSUE_DESCRIPTION="A merge conflict has occurred and must be resolved manually.
 
@@ -65,3 +65,28 @@ if git show -s --oneline HEAD | grep -q "AUTOMATIC: New 
configs"; then
 else
        printf "No new configuration values exposed from merging %s into 
$BRANCH\n" "$UPSTREAM_REF"
 fi
+
+if test -n "$DIST_PUSH"; then
+       echo "Pushing branch $(git branch --show-current) to $(get remote 
get-url gitlab)"
+       git push gitlab HEAD
+
+       echo "Pushing config update branches"
+       for branch in $(git branch | grep configs/"$(date +%F)"); do
+               git push \
+                       -o merge_request.create \
+                       -o merge_request.target="$BRANCH" \
+                       -o merge_request.remove_source_branch \
+                       gitlab "$branch"
+       done
+else
+       printf "
+To push all the release artifacts, run:
+
+git push gitlab HEAD
+for branch in \$(git branch | grep configs/\"\$(date +%%F)\"); do
+\tgit push -o merge_request.create -o merge_request.target=$BRANCH\
+ -o merge_request.remove_source_branch upstream gitlab \"\$branch\"
+done\n"
+
+fi
+
-- 
GitLab
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org

Reply via email to