diff --git a/scripts/copy/Readme.txt b/scripts/copy/Readme.txt new file mode 100644 index 0000000000000..38609e09ba9e1 --- /dev/null +++ b/scripts/copy/Readme.txt @@ -0,0 +1,11 @@ +The purposes of these scripts is to copy some subfolder to jb-main branch from "integration" or "integration-release/*". + +1. Checkout the commit you want to copy ("integration" or "integration-release/*") + +2. Merge jb-main to integration, pick "jb-main" state in a case of conflicts in other folders + +3. Call `./copyCompose.sh` (use another script for another folder) + +It creates 2 branches: +- integration-copy/$hash/to-jb-main - should be merged to "jb-main". It is based on merge-base(currentCommit, jb-main) and has the copy of the subfolder from currentCommit +- integration-copy/$hash/to-integration - should be merged to "integration", to avoid conflicts in future merges of jb-main. It is created as "empty" merge of "to-jb-main" to merge-base(currentCommit, integration) diff --git a/scripts/copy/copyAnnotation.sh b/scripts/copy/copyAnnotation.sh new file mode 100644 index 0000000000000..a89f11a2b44be --- /dev/null +++ b/scripts/copy/copyAnnotation.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'annotation' \ No newline at end of file diff --git a/scripts/copy/copyCollection.sh b/scripts/copy/copyCollection.sh new file mode 100644 index 0000000000000..252ede36d79a1 --- /dev/null +++ b/scripts/copy/copyCollection.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'collection' \ No newline at end of file diff --git a/scripts/copy/copyCompose.sh b/scripts/copy/copyCompose.sh new file mode 100644 index 0000000000000..5761333aaaffd --- /dev/null +++ b/scripts/copy/copyCompose.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'compose' ':(exclude)compose/material3' ':(exclude)compose/compiler' \ No newline at end of file diff --git a/scripts/copy/copyComposeMaterial3.sh b/scripts/copy/copyComposeMaterial3.sh new file mode 100644 index 0000000000000..ab40d90c582c8 --- /dev/null +++ b/scripts/copy/copyComposeMaterial3.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'compose/material3' ':(exclude)compose/material3/adaptive' \ No newline at end of file diff --git a/scripts/copy/copyComposeMaterial3Adaptive.sh b/scripts/copy/copyComposeMaterial3Adaptive.sh new file mode 100644 index 0000000000000..baec25b547c8b --- /dev/null +++ b/scripts/copy/copyComposeMaterial3Adaptive.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'compose/material3/adaptive' \ No newline at end of file diff --git a/scripts/copy/copyLifecycle.sh b/scripts/copy/copyLifecycle.sh new file mode 100644 index 0000000000000..153a64dd88e7d --- /dev/null +++ b/scripts/copy/copyLifecycle.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'lifecycle' \ No newline at end of file diff --git a/scripts/copy/copyMaterial3.sh b/scripts/copy/copyMaterial3.sh new file mode 100644 index 0000000000000..d51e47288ce03 --- /dev/null +++ b/scripts/copy/copyMaterial3.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'compose/material3' \ No newline at end of file diff --git a/scripts/copy/copyNavigation.sh b/scripts/copy/copyNavigation.sh new file mode 100644 index 0000000000000..289a56071d719 --- /dev/null +++ b/scripts/copy/copyNavigation.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'navigation' \ No newline at end of file diff --git a/scripts/copy/copySavedstate.sh b/scripts/copy/copySavedstate.sh new file mode 100644 index 0000000000000..35401b88dbb95 --- /dev/null +++ b/scripts/copy/copySavedstate.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'savedstate' \ No newline at end of file diff --git a/scripts/copy/copyWindow.sh b/scripts/copy/copyWindow.sh new file mode 100644 index 0000000000000..251108287a13d --- /dev/null +++ b/scripts/copy/copyWindow.sh @@ -0,0 +1 @@ +$(dirname "$0")/impl/copyToJbMain.sh 'window' \ No newline at end of file diff --git a/scripts/copy/impl/copyToJbMain.sh b/scripts/copy/impl/copyToJbMain.sh new file mode 100644 index 0000000000000..eae6a1174ffa6 --- /dev/null +++ b/scripts/copy/impl/copyToJbMain.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# This script is rarely needed to be used explicitly. +# Use parent scripts and see the parent Readme.md + +set -e + +if [ -z "$1" ]; then +echo "Specify folders to copy to jb-main. For example: ./copyToJbMain.sh compose ':(exclude)compose/material3'" +exit 1 +fi + +DIR=$(dirname "$0") +ROOT_DIR="$(dirname "$0")/../../.." +ALL_FOLDERS=${@:1} +FIRST_FOLDER=$1 +FIRST_FOLDER=${FIRST_FOLDER////-} # replace / by - +CURRENT_COMMIT=$(git rev-parse --short @) +BRANCH_TO_RESTORE_IN_THE_END=$(git branch --show-current) + + +JB_MAIN_BRANCH=$(git config branch.jb-main.remote)/jb-main +TO_JB_MAIN_BRANCH=integration-copy/$FIRST_FOLDER/$CURRENT_COMMIT/to-jb-main +git checkout --quiet $(git merge-base $CURRENT_COMMIT $JB_MAIN_BRANCH) -B $TO_JB_MAIN_BRANCH +( + cd $ROOT_DIR; + git checkout --quiet --no-overlay $CURRENT_COMMIT -- $ALL_FOLDERS; + git commit --quiet -m "Copy $FIRST_FOLDER from $CURRENT_COMMIT" +) +echo "Created $TO_JB_MAIN_BRANCH" + +INTEGRATION_BRANCH=$(git config branch.integration.remote)/integration +TO_INTEGRATION_BRANCH=integration-copy/$FIRST_FOLDER/$CURRENT_COMMIT/to-integration +git checkout --quiet $(git merge-base $CURRENT_COMMIT $INTEGRATION_BRANCH) -B $TO_INTEGRATION_BRANCH +$DIR/mergeEmpty.sh $TO_JB_MAIN_BRANCH +echo "Created $TO_INTEGRATION_BRANCH" + + +git checkout --quiet $BRANCH_TO_RESTORE_IN_THE_END \ No newline at end of file diff --git a/scripts/mergeEmpty.sh b/scripts/copy/impl/mergeEmpty.sh old mode 100755 new mode 100644 similarity index 78% rename from scripts/mergeEmpty.sh rename to scripts/copy/impl/mergeEmpty.sh index 274b584d7534a..c43291efa2f8c --- a/scripts/mergeEmpty.sh +++ b/scripts/copy/impl/mergeEmpty.sh @@ -1,5 +1,7 @@ #!/bin/bash +## !!! Be careful using this script separately from the main scripts in the parent folder +## ## This script merges a commit with discarding all the changes in it. ## It is useful when you don't want to merge some changes, but want to change a base commit, solving all future conflicts. @@ -12,7 +14,7 @@ fi COMMIT=$1 -ROOT_DIR="$(dirname "$0")/.." +ROOT_DIR="$(dirname "$0")/../../.." ( cd $ROOT_DIR; diff --git a/scripts/snapSubfolder.sh b/scripts/snapSubfolder.sh deleted file mode 100755 index 8e73a60970f55..0000000000000 --- a/scripts/snapSubfolder.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -## This script set the state of a subfolder to the state in some commit, creating a merge commit. -## Warning!!! Snapping subfolders breaks the base commit and future merges of the destination branch. To fix it, merge the destination branch back to the source branch, discarding all changes. - -set -e - -if [ -z "$1" ]; then -echo "Specify the snapping commit and the subfolder. For example: ./snapSubfolder.sh androidx/compose-material3/1.2.0-alpha02 compose/material3/material3" -exit 1 -fi - -if [ -z "$2" ]; then -echo "Specify the snapping commit and the subfolder. For example: ./snapSubfolder.sh androidx/compose-material3/1.2.0-alpha02 compose/material3/material3" -exit 1 -fi - -COMMIT=$1 -FOLDER=$2 - -ROOT_DIR="$(dirname "$0")/.." - -( - cd $ROOT_DIR; - git checkout --no-overlay $COMMIT -- $FOLDER; - NEW_COMMIT=$(git commit-tree -p HEAD -p $COMMIT -m"Snap $COMMIT, subfolder $FOLDER" $(git write-tree)); - git reset --hard $NEW_COMMIT; -)