Skip to content
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

Simplified scripts for copying to jb-main #1407

Merged
merged 18 commits into from
Oct 2, 2024
Merged
11 changes: 11 additions & 0 deletions scripts/copy/Readme.txt
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions scripts/copy/copyAnnotation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'annotation'
1 change: 1 addition & 0 deletions scripts/copy/copyCollection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'collection'
1 change: 1 addition & 0 deletions scripts/copy/copyCompose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'compose' ':(exclude)compose/material3' ':(exclude)compose/compiler'
1 change: 1 addition & 0 deletions scripts/copy/copyComposeMaterial3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'compose/material3' ':(exclude)compose/material3/adaptive'
1 change: 1 addition & 0 deletions scripts/copy/copyComposeMaterial3Adaptive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'compose/material3/adaptive'
1 change: 1 addition & 0 deletions scripts/copy/copyLifecycle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'lifecycle'
1 change: 1 addition & 0 deletions scripts/copy/copyMaterial3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'compose/material3'
1 change: 1 addition & 0 deletions scripts/copy/copyNavigation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'navigation'
1 change: 1 addition & 0 deletions scripts/copy/copySavedstate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'savedstate'
1 change: 1 addition & 0 deletions scripts/copy/copyWindow.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/copyToJbMain.sh 'window'
39 changes: 39 additions & 0 deletions scripts/copy/impl/copyToJbMain.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion scripts/mergeEmpty.sh → scripts/copy/impl/mergeEmpty.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -12,7 +14,7 @@ fi

COMMIT=$1

ROOT_DIR="$(dirname "$0")/.."
ROOT_DIR="$(dirname "$0")/../../.."

(
cd $ROOT_DIR;
Expand Down
28 changes: 0 additions & 28 deletions scripts/snapSubfolder.sh

This file was deleted.