Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions inkless-sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Context for the agent:
### Sync Before New Kafka Version
Comment thread
tvainika marked this conversation as resolved.
Outdated

```bash
# Sync to the commit just before a version tag (e.g., before 4.3)
# Sync to the trunk commit where the 4.3 release branch diverged from trunk
Comment thread
tvainika marked this conversation as resolved.
Outdated
./inkless-sync/main-sync.sh --before-version 4.3
```
Comment thread
tvainika marked this conversation as resolved.

Expand Down Expand Up @@ -147,7 +147,8 @@ For detailed cherry-pick workflow, conflict resolution patterns, and session tra

### Phase 1: Preparation
1. Fetches upstream apache/kafka
2. Determines sync target (trunk HEAD or before-version)
2. Determines sync target (trunk HEAD, or trunk's merge base with the
`--before-version` release branch)
3. Generates "inkless manifest" - list of files we've modified
4. Creates sync branch: `sync/upstream-YYYYMMDD`

Expand Down
11 changes: 9 additions & 2 deletions inkless-sync/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,17 @@ get_base_version() {
echo "$version"
}

# Check if a tag exists
# Check if a tag (not a branch) exists
tag_exists() {
local tag="$1"
git rev-parse "$tag" &> /dev/null
git rev-parse --verify --quiet "refs/tags/${tag}" &> /dev/null
}

# Check if a branch exists, local or remote-tracking (not a tag)
branch_exists() {
local branch="$1"
git rev-parse --verify --quiet "refs/heads/${branch}" &> /dev/null \
|| git rev-parse --verify --quiet "refs/remotes/${branch}" &> /dev/null
}

# Get commit hash for a tag (dereference annotated tags)
Expand Down
20 changes: 11 additions & 9 deletions inkless-sync/main-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#
# Options:
# --target <ref> Git ref to sync to (default: apache/trunk HEAD)
# --before-version <v> Find last commit before version tag (e.g., "4.3")
# --before-version <v> Sync to the trunk commit where release branch "v"
# (e.g., "4.3") diverged from apache/trunk
# --dry-run Show what would be done without making changes
# --help Show this help message
#
Expand Down Expand Up @@ -161,15 +162,16 @@ phase_prepare() {

# Determine sync target
if [[ -n "$BEFORE_VERSION" ]]; then
log_info "Finding last commit before version ${BEFORE_VERSION}..."
# Find the commit just before the version tag
if ! tag_exists "${BEFORE_VERSION}"; then
log_error "Tag ${BEFORE_VERSION} not found"
log_info "Finding trunk commit before version ${BEFORE_VERSION} diverged..."
Comment thread
tvainika marked this conversation as resolved.
Outdated
# The release branch (apache/$BEFORE_VERSION) can carry commits that
# never land on trunk. Use the merge base with trunk so the sync only
# picks up commits that are actually part of trunk history.
if ! branch_exists "${APACHE_REMOTE}/${BEFORE_VERSION}"; then
log_error "Branch ${APACHE_REMOTE}/${BEFORE_VERSION} not found"
exit 1
fi
# Get parent of the version tag
TARGET=$(git rev-parse "${BEFORE_VERSION}^")
log_info "Target: ${TARGET} (parent of ${BEFORE_VERSION})"
TARGET=$(git merge-base "${APACHE_REMOTE}/trunk" "${APACHE_REMOTE}/${BEFORE_VERSION}")
log_info "Target: ${TARGET} (merge base of ${APACHE_REMOTE}/trunk and ${APACHE_REMOTE}/${BEFORE_VERSION})"
elif [[ -z "$TARGET" ]]; then
TARGET="${APACHE_REMOTE}/trunk"
log_info "Target: ${TARGET} (trunk HEAD)"
Expand Down Expand Up @@ -306,7 +308,7 @@ phase_merge() {
# Attempt merge
MERGE_MSG="merge: apache/kafka trunk"
if [[ -n "$BEFORE_VERSION" ]]; then
MERGE_MSG="merge: apache/kafka trunk before ${BEFORE_VERSION}"
MERGE_MSG="merge: apache/kafka trunk before ${APACHE_REMOTE}/${BEFORE_VERSION} diverged"
fi

if git merge "$TARGET_COMMIT" -m "$MERGE_MSG" --no-edit --no-ff; then
Expand Down
Loading