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

Open
wants to merge 17 commits into
base: jb-main
Choose a base branch
from
7 changes: 7 additions & 0 deletions scripts/snap/Readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The purposes of these scripts is to merge some subfolder to jb-main branch from other branch (usually it is "integration" or "integration-release/something").

The HEAD should be on the commit which you want to merge.

It creates 2 branches:
- integration-snap/$hash/to-jb-main - should be merged to jb-main. It is created from the merging currentCommit to merge-base(currentCommit, jb-main)
- integration-snap/$hash/to-integration - should be merged to integration, to avoid conflicts in future merges of jb-main. It is createad as "empty" merge of "to-jb-main" to merge-base(currentCommit, integration)
4 changes: 3 additions & 1 deletion scripts/mergeEmpty.sh → scripts/snap/impl/mergeEmpty.sh
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
31 changes: 31 additions & 0 deletions scripts/snap/impl/snapSubfolder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

## !!! Be careful using this script separately from the main scripts in the parent folder
##
## 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 subfolders. For example: ./snapSubfolder.sh androidx/compose-ui/1.6.0-alpha02 compose ':(exclude)compose/material3'"
exit 1
fi

if [ -z "$2" ]; then
echo "Specify the snapping commit and the subfolders. For example: ./snapSubfolder.sh androidx/compose-ui/1.6.0-alpha02 compose ':(exclude)compose/material3'"
exit 1
fi

COMMIT=$1
FIRST_FOLDER=$2
ALL_FOLDERS=${@:2}

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

(
cd $ROOT_DIR;
git checkout --no-overlay $COMMIT -- $ALL_FOLDERS;
NEW_COMMIT=$(git commit-tree -p HEAD -p $COMMIT -m"Snap $COMMIT, subfolder $FIRST_FOLDER" $(git write-tree));
git reset --hard $NEW_COMMIT;
)
27 changes: 27 additions & 0 deletions scripts/snap/impl/snapToJbMain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

if [ -z "$1" ]; then
echo "Specify the snapping subfolder. For example: ./snapToJbMain.sh androidx/compose-ui/1.6.0-alpha02 compose ':(exclude)compose/material3'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Description for args is not clear. What is branch? Out? In? Is it possible to specify hash? What is folder? What should be current git branch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be used explicitly. Added a comment to look the parent scripts/readme

exit 1
fi

DIR=$(dirname "$0")
ALL_FOLDERS=${@:1}
CURRENT_COMMIT=$(git rev-parse --short @)
BRANCH_TO_RESTORE_IN_THE_END=$(git branch --show-current)


TO_JB_MAIN_BRANCH=integration-snap/$CURRENT_COMMIT/to-jb-main
git checkout --quiet $(git merge-base $CURRENT_COMMIT origin/jb-main) -B $TO_JB_MAIN_BRANCH
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't work for my case: remote can have not "origin" name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed. local branches should be up-to-date to this point anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local branches should be up-to-date to this point anyway.

Actually, I am wrong, all work can be done in "integration" without updating "jb-main".

Fixed reading the associated remote.

$DIR/snapSubfolder.sh $CURRENT_COMMIT $ALL_FOLDERS
echo "Created $TO_JB_MAIN_BRANCH"

TO_INTEGRATION_BRANCH=integration-snap/$CURRENT_COMMIT/to-integration
git checkout --quiet $(git merge-base $CURRENT_COMMIT origin/integration) -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
1 change: 1 addition & 0 deletions scripts/snap/snapAnnotation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/snapToJbMain.sh 'compose/annotation'
igordmn marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions scripts/snap/snapCollection.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/snapToJbMain.sh 'compose/collection'
igordmn marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions scripts/snap/snapCompose.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/snapToJbMain.sh 'compose' ':(exclude)compose/material3'
1 change: 1 addition & 0 deletions scripts/snap/snapComposeMaterial3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/snapToJbMain.sh 'compose/material3'
1 change: 1 addition & 0 deletions scripts/snap/snapLifecycle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/snapToJbMain.sh 'compose/lifecycle'
igordmn marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions scripts/snap/snapMaterial3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/snapToJbMain.sh 'compose/material3'
1 change: 1 addition & 0 deletions scripts/snap/snapNavigation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/snapToJbMain.sh 'compose/navigation'
igordmn marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions scripts/snap/snapSavedstate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(dirname "$0")/impl/snapToJbMain.sh 'compose/savedstate'
igordmn marked this conversation as resolved.
Show resolved Hide resolved
28 changes: 0 additions & 28 deletions scripts/snapSubfolder.sh

This file was deleted.

Loading