Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
46 changes: 35 additions & 11 deletions Scripts/bump_ag_pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ Usage: $SCRIPT_NAME [branch] [--force] [--help]
Automated script to update DarwinPrivateFrameworks with AttributeGraph changes.

Arguments:
branch Target branch to generate from (default: main)
branch Target branch to generate from (default: current branch)

Options:
--force Force push the branch when creating PR
--help Show this help message

Examples:
$SCRIPT_NAME # Update from main branch
$SCRIPT_NAME # Update from current branch
$SCRIPT_NAME develop # Update from develop branch
$SCRIPT_NAME main --force # Update from main with force push
$SCRIPT_NAME --help # Show this help

Description:
This script automates the process of updating DarwinPrivateFrameworks
with the latest AttributeGraph changes by:
1. Setting up a git worktree for the target branch
1. Setting up a git worktree for the target branch (if not current branch)
2. Cloning DarwinPrivateFrameworks repository
3. Generating AG template from OpenAttributeGraph
4. Updating headers and Swift interface templates
Expand All @@ -42,7 +42,7 @@ EOF
}

# Parse command line arguments
TARGET_BRANCH="main"
TARGET_BRANCH=""
FORCE_PUSH=""

# Parse arguments
Expand All @@ -64,10 +64,30 @@ while [[ $# -gt 0 ]]; do
done

SCRIPT_ROOT="$(dirname $(dirname $(filepath $0)))"

# Get current branch if no target branch specified
if [[ -z "$TARGET_BRANCH" ]]; then
cd "$SCRIPT_ROOT"
TARGET_BRANCH="$(git branch --show-current)"
if [[ -z "$TARGET_BRANCH" ]]; then
echo "Error: Could not determine current branch and no branch specified"
exit 1
fi
fi

OAG_REPO_DIR="$SCRIPT_ROOT/.oag_repo"
OPENATTRIBUTEGRAPH_ROOT="$OAG_REPO_DIR"
AG_REPO_DIR="$SCRIPT_ROOT/.ag_repo"

# Check if we're already on the target branch
cd "$SCRIPT_ROOT"
CURRENT_BRANCH="$(git branch --show-current)"
USE_WORKTREE=true
if [[ "$CURRENT_BRANCH" == "$TARGET_BRANCH" ]]; then
USE_WORKTREE=false
OPENATTRIBUTEGRAPH_ROOT="$SCRIPT_ROOT"
fi

echo "Starting DarwinPrivateFrameworks bump PR workflow..."
echo "Target branch: $TARGET_BRANCH"
if [[ -n "$FORCE_PUSH" ]]; then
Expand All @@ -80,7 +100,7 @@ cleanup() {
echo "Cleaning up temporary repository..."
rm -rf "$AG_REPO_DIR"
fi
if [[ -d "$OAG_REPO_DIR" ]]; then
if [[ "$USE_WORKTREE" == true ]] && [[ -d "$OAG_REPO_DIR" ]]; then
echo "Cleaning up git worktree..."
cd "$SCRIPT_ROOT"
git worktree remove --force "$OAG_REPO_DIR" 2>/dev/null || true
Expand All @@ -92,13 +112,17 @@ trap cleanup EXIT

cd "$SCRIPT_ROOT"

# Step 1: Setup git worktree for target branch
echo "Setting up git worktree for branch: $TARGET_BRANCH"
if [[ -d "$OAG_REPO_DIR" ]]; then
git worktree remove --force "$OAG_REPO_DIR" 2>/dev/null || true
fi
# Step 1: Setup git worktree for target branch (if needed)
if [[ "$USE_WORKTREE" == true ]]; then
echo "Setting up git worktree for branch: $TARGET_BRANCH"
if [[ -d "$OAG_REPO_DIR" ]]; then
git worktree remove --force "$OAG_REPO_DIR" 2>/dev/null || true
fi

git worktree add "$OAG_REPO_DIR" "$TARGET_BRANCH"
git worktree add "$OAG_REPO_DIR" "$TARGET_BRANCH"
else
echo "Using current directory (already on target branch)"
fi

# Step 2: Clone DarwinPrivateFrameworks repository
echo "Cloning DarwinPrivateFrameworks repository..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public struct WeakAttribute<Value> {

public var value: Value? { wrappedValue }

public func changedValue(options: OAGValueOptions) -> (value: Value, changed: Bool)? {
public func changedValue(options: OAGValueOptions = []) -> (value: Value, changed: Bool)? {
let value = OAGGraphGetWeakValue(base, options: options, type: Value.self)
guard let ptr = value.value else {
return nil
Expand Down
Loading