Skip to content

Commit

Permalink
Simplified scripts for copying to jb-main (#1407)
Browse files Browse the repository at this point in the history
Now we need only to switch to the commit, and call a needed script. It
creates 2 branches, which can be tested on CI, and merged with simple
git merge.

Branches:
<img width="563" alt="image"
src="https://github.com/user-attachments/assets/42fdc40c-7729-42d3-9e28-a216ed0106f1">

---------

Co-authored-by: Ivan Matkov <[email protected]>
  • Loading branch information
igordmn and MatkovIvan authored Oct 2, 2024
1 parent 938597a commit 411b73e
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 29 deletions.
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.

0 comments on commit 411b73e

Please sign in to comment.