Skip to content

Commit d82a006

Browse files
author
nejc
committed
feat: improve branch configuration flexibility and clarity
- Remove hardcoded 'main' branch forcing in UpstreamPrCommand - Allow any upstream branch to be configured (main, master, develop, etc.) - Improve setup command prompts with clear explanations - Add detailed branch configuration documentation in README - Clarify difference between upstream branch and local branch - Add examples for different project scenarios (legacy, dev branches) - Update environment variable documentation with comments Now supports: - UPSTREAM_BRANCH: Branch in upstream repo to pull from - UPSTREAM_LOCAL_BRANCH: Your main project branch for PRs - Clear setup prompts explaining what each branch is for - Flexible configuration for any Git workflow Fixes issues with projects using master/dev branches instead of main.
1 parent 6fd6426 commit d82a006

File tree

3 files changed

+50
-25
lines changed

3 files changed

+50
-25
lines changed

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ php artisan laravelplus:setup --preset=custom --url=https://github.com/your-org/
103103

104104
## Configuration
105105

106+
### Branch Configuration Explained
107+
108+
The package uses two important branch settings:
109+
110+
- **`UPSTREAM_BRANCH`**: The branch in the upstream repository to pull changes from (e.g., `main`, `master`, `develop`)
111+
- **`UPSTREAM_LOCAL_BRANCH`**: Your main project branch where PRs will be created against (e.g., `main`, `master`, `develop`)
112+
113+
**Example scenarios:**
114+
- **Laravel Starter Kit**: `UPSTREAM_BRANCH=main` (upstream repo) → `UPSTREAM_LOCAL_BRANCH=main` (your repo)
115+
- **Legacy Project**: `UPSTREAM_BRANCH=main` (upstream repo) → `UPSTREAM_LOCAL_BRANCH=master` (your repo)
116+
- **Development Branch**: `UPSTREAM_BRANCH=develop` (upstream repo) → `UPSTREAM_LOCAL_BRANCH=develop` (your repo)
117+
118+
### Publish Configuration
119+
106120
Publish the configuration file:
107121

108122
```bash
@@ -142,21 +156,30 @@ return [
142156
Add these to your `.env` file:
143157

144158
```env
159+
# Upstream repository configuration
145160
UPSTREAM_URL=https://github.com/your-upstream/repo.git
146-
UPSTREAM_BRANCH=main
147-
UPSTREAM_LOCAL_BRANCH=main
161+
UPSTREAM_BRANCH=main # Branch in upstream repo to pull from
162+
UPSTREAM_LOCAL_BRANCH=main # Your main project branch (PRs created against this)
148163
UPSTREAM_STRATEGY=merge
149164
UPSTREAM_COMMIT_MESSAGE="chore(upstream): sync from upstream"
150165
UPSTREAM_ALLOW_UNRELATED=true
166+
167+
# Preset configuration
151168
UPSTREAM_DEFAULT_PRESET=vue
152169
UPSTREAM_AUTO_DETECT=true
170+
171+
# PR configuration
153172
UPSTREAM_CREATE_PR=false
154173
UPSTREAM_PR_BRANCH_PREFIX=upstream-sync-
155174
UPSTREAM_PR_TITLE="chore: sync from upstream"
156175
UPSTREAM_PR_BODY="Automated upstream sync from {upstream_url}"
176+
177+
# GitHub integration
157178
GITHUB_TOKEN=your_github_token
158179
GITHUB_OWNER=your_username
159180
GITHUB_REPO=your_repo
181+
182+
# Git configuration
160183
GIT_BINARY=git
161184
```
162185

src/Console/Commands/UpstreamPrCommand.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,8 @@ public function handle(): int
7878
$localBranch = $currentBranch;
7979
}
8080

81-
// Upstream branch is always 'main' for Laravel starter kits
82-
if ($upstreamBranch !== 'main') {
83-
$this->line("📍 Using upstream branch: <info>main</info> (configured: $upstreamBranch)");
84-
$upstreamBranch = 'main';
85-
}
81+
// Use configured upstream branch (defaults to 'main' for Laravel starter kits)
82+
$this->line("📍 Using upstream branch: <info>$upstreamBranch</info>");
8683
$allowUnrelated = (bool) $cfg['allow_unrelated_histories'];
8784
$dry = (bool) $this->option('dry-run');
8885

src/Console/Commands/UpstreamSetupCommand.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,26 @@ private function setupPreset(string $preset): int
8282
$this->info("Setting up upstream sync for Laravel $preset starter kit...");
8383
$this->newLine();
8484

85-
// Use main branch for Laravel starter kits (standard)
86-
$branch = 'main';
87-
$this->line("🌿 Upstream branch: <info>$branch</info> (standard for Laravel starter kits)");
85+
// Ask for upstream branch (what branch to pull from in the upstream repo)
86+
$upstreamBranch = $this->text(
87+
'Which branch should we pull from in the upstream repository?',
88+
default: 'main',
89+
placeholder: 'e.g., main, master, develop (this is the branch in the upstream repo)'
90+
);
91+
92+
$this->line("🌿 Upstream branch: <info>$upstreamBranch</info> (branch in {$config['upstream_url']})");
8893

89-
// Ask for local branch
94+
// Ask for local branch (what branch to create PRs against)
9095
$localBranch = $this->text(
91-
'Which local branch should receive the updates?',
92-
default: $branch,
93-
placeholder: 'e.g., main, develop, feature-branch'
96+
'Which local branch should receive the updates? (PRs will be created against this branch)',
97+
default: 'main',
98+
placeholder: 'e.g., main, master, develop (your main project branch)'
9499
);
95100

96101
// Update .env file
97102
$this->updateEnvFile([
98103
'UPSTREAM_URL' => $config['upstream_url'],
99-
'UPSTREAM_BRANCH' => $branch,
104+
'UPSTREAM_BRANCH' => $upstreamBranch,
100105
'UPSTREAM_LOCAL_BRANCH' => $localBranch,
101106
'UPSTREAM_PRESET' => $preset,
102107
]);
@@ -110,8 +115,8 @@ private function setupPreset(string $preset): int
110115
$this->info("✅ Setup complete for Laravel $preset starter kit!");
111116
$this->line('📝 Configuration added to .env file');
112117
$this->line("🔗 Upstream URL: {$config['upstream_url']}");
113-
$this->line("🌿 Upstream Branch: $branch");
114-
$this->line("📍 Local Branch: $localBranch");
118+
$this->line("🌿 Upstream Branch: $upstreamBranch (branch in upstream repo)");
119+
$this->line("📍 Local Branch: $localBranch (your main project branch)");
115120

116121
$this->newLine();
117122
$this->line('💡 You can now run: <info>php artisan laravelplus:check</info>');
@@ -132,16 +137,16 @@ private function setupCustom(): int
132137
return self::FAILURE;
133138
}
134139

135-
$branch = $this->text(
136-
'Enter upstream branch name',
140+
$upstreamBranch = $this->text(
141+
'Which branch should we pull from in the upstream repository?',
137142
default: 'main',
138-
placeholder: 'usually "main" for Laravel projects'
143+
placeholder: 'e.g., main, master, develop (this is the branch in the upstream repo)'
139144
);
140145

141146
$localBranch = $this->text(
142-
'Enter local branch name',
147+
'Which local branch should receive the updates? (PRs will be created against this branch)',
143148
default: 'main',
144-
placeholder: 'where updates will be applied'
149+
placeholder: 'e.g., main, master, develop (your main project branch)'
145150
);
146151

147152
$this->info('Setting up upstream sync for custom repository...');
@@ -150,7 +155,7 @@ private function setupCustom(): int
150155
// Update .env file
151156
$this->updateEnvFile([
152157
'UPSTREAM_URL' => $url,
153-
'UPSTREAM_BRANCH' => $branch,
158+
'UPSTREAM_BRANCH' => $upstreamBranch,
154159
'UPSTREAM_LOCAL_BRANCH' => $localBranch,
155160
'UPSTREAM_PRESET' => 'custom',
156161
]);
@@ -159,8 +164,8 @@ private function setupCustom(): int
159164
$this->info('✅ Custom setup complete!');
160165
$this->line('📝 Configuration added to .env file');
161166
$this->line("🔗 Upstream URL: $url");
162-
$this->line("🌿 Upstream Branch: $branch");
163-
$this->line("📍 Local Branch: $localBranch");
167+
$this->line("🌿 Upstream Branch: $upstreamBranch (branch in upstream repo)");
168+
$this->line("📍 Local Branch: $localBranch (your main project branch)");
164169

165170
$this->newLine();
166171
$this->line('💡 You can now run: <info>php artisan laravelplus:check</info>');

0 commit comments

Comments
 (0)