Update fork updater script

This commit is contained in:
Katrina Verey
2021-07-15 08:20:07 -07:00
parent 34981b664f
commit 9538ae1258
2 changed files with 17 additions and 16 deletions

View File

@@ -6,6 +6,6 @@ This code is used by the starlark runtime. We copied it in to reduce the depende
## go-yaml/yaml ## go-yaml/yaml
This code is used extensively by kyaml. It is a copy of upstream at a particular revision that kubectl is using, with [a change we need](https://github.com/go-yaml/yaml/pull/753) cherry-picked on top. For background information on this problem, see https://github.com/kubernetes-sigs/kustomize/issues/3946. This code is used extensively by kyaml. It is a copy of upstream at a particular revision that kubectl is using, with fixes we need cherry-picked on top ([#753](https://github.com/go-yaml/yaml/pull/753), [#766](https://github.com/go-yaml/yaml/pull/766)). For background information on this problem, see https://github.com/kubernetes-sigs/kustomize/issues/3946.
This copy was created using the [git subtree technique](https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec) and can be recreated on top of a new version of go-yaml v3 using the [update-go-yaml.sh](update-go-yaml.sh) script. Please note that there is nothing special about the fork directory, so copy-paste with manual edits will work just fine if you prefer. This copy was created using the [git subtree technique](https://medium.com/@porteneuve/mastering-git-subtrees-943d29a798ec) and can be recreated on top of a new version of go-yaml v3 using the [update-go-yaml.sh](update-go-yaml.sh) script. To add an additional go-yaml PR to be cherry-picked, simply update the script's `GO_YAML_PRS` variable. Please note that there is nothing special about the fork directory, so copy-paste with manual edits will work just fine if you prefer.

View File

@@ -23,8 +23,7 @@ normal=$(tput sgr0)
export GOYAML_REF="goyaml-$GOYAML_SHA" export GOYAML_REF="goyaml-$GOYAML_SHA"
# The PRs we need to cherry-pick onto the above commit # The PRs we need to cherry-pick onto the above commit
declare -r GO_YAML_PR=753 declare -r GO_YAML_PRS=(753 766)
declare -r KUSTOMIZE_PR=4004
REPO_ROOT=$(git rev-parse --show-toplevel) REPO_ROOT=$(git rev-parse --show-toplevel)
declare -r REPO_ROOT declare -r REPO_ROOT
@@ -77,8 +76,11 @@ function cherry-pick(){
subtree_commit_flag="" subtree_commit_flag=""
explain "Removing the fork's tree from git, if it exists. We'll write over this commit in a moment, but \`read-tree\` requires a clean directory." explain "Removing the fork's tree from git, if it exists. We'll write over this commit in a moment, but \`read-tree\` requires a clean directory."
if [[ $(find kyaml/internal/forked/github.com/go-yaml/yaml -type f -delete) ]]; then find kyaml/internal/forked/github.com/go-yaml/yaml -type f -delete
git commit --all -m "Temporarily remove go-yaml fork"
if [[ $(git diff --exit-code kyaml/internal/forked/github.com/go-yaml/yaml) ]]; then
git add kyaml/internal/forked/github.com/go-yaml/yaml
git commit -m "Temporarily remove go-yaml fork"
subtree_commit_flag="--amend" subtree_commit_flag="--amend"
fi fi
@@ -87,21 +89,20 @@ git fetch --depth=1 https://github.com/go-yaml/yaml.git "$GOYAML_SHA:$GOYAML_REF
explain "Inserting the content we just pulled as a subtree of this repository and squash the changes into the last commit." explain "Inserting the content we just pulled as a subtree of this repository and squash the changes into the last commit."
git read-tree --prefix=kyaml/internal/forked/github.com/go-yaml/yaml/ -u "$GOYAML_REF" git read-tree --prefix=kyaml/internal/forked/github.com/go-yaml/yaml/ -u "$GOYAML_REF"
git commit $subtree_commit_flag --all -m "Internal copy of go-yaml at $GOYAML_SHA" git add kyaml/internal/forked/github.com/go-yaml/yaml
git commit $subtree_commit_flag -m "Internal copy of go-yaml at $GOYAML_SHA"
explain "Subtree creation successful." explain "Subtree creation successful."
explain "Cherry-picking the commits from our go-yaml/yaml PR" explain "Cherry-picking the commits from our go-yaml/yaml PRs"
cherry-pick https://github.com/go-yaml/yaml $GO_YAML_PR for pr in "${GO_YAML_PRS[@]}" ; do
cherry-pick https://github.com/go-yaml/yaml "$pr"
done
explain "Converting module to be internal." explain "Converting module to be internal."
find kyaml/internal/forked/github.com/go-yaml/yaml -name "*.go" -type f | xargs sed -i '' s+"gopkg.in/yaml.v3"+"sigs.k8s.io/kustomize/kyaml/internal/forked/github.com/go-yaml/yaml"+g find kyaml/internal/forked/github.com/go-yaml/yaml -name "*.go" -type f | xargs sed -i '' s+"gopkg.in/yaml.v3"+"sigs.k8s.io/kustomize/kyaml/internal/forked/github.com/go-yaml/yaml"+g
rm kyaml/internal/forked/github.com/go-yaml/yaml/go.mod rm kyaml/internal/forked/github.com/go-yaml/yaml/go.mod
git commit --all -m "Internalize forked code" git commit --all -m "Internalize forked code"
# This is only necessary in the initial forking of the code
# explain "Cherry-picking the commits from our test fixes in Kustomize PR"
# cherry-pick https://github.com/kubernetes-sigs/kustomize $KUSTOMIZE_PR
explain "SUCCEEDED." explain "SUCCEEDED."
exit 0 exit 0