Skip to content

Commit 900eb7e

Browse files
author
nejc
committed
feat: enhance check command with detailed commit information
- Add detailed commit information showing commit messages and dates - Show which upstream commit will be used for PR creation - Display last sync information when up to date - Add commit details section with local and upstream commit info - Show timestamps for better tracking of update timing - Improve user visibility into what commits are being tracked Enhanced output now shows: - Commit messages for both local and upstream - Last updated timestamps - Which upstream commit will be used for PR - Better context for decision making
1 parent d82a006 commit 900eb7e

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,22 @@ The package uses two important branch settings:
111111
- **`UPSTREAM_LOCAL_BRANCH`**: Your main project branch where PRs will be created against (e.g., `main`, `master`, `develop`)
112112

113113
**Example scenarios:**
114-
- **Laravel Starter Kit**: `UPSTREAM_BRANCH=main` (upstream repo) → `UPSTREAM_LOCAL_BRANCH=main` (your repo)
114+
- **Modern Project**: `UPSTREAM_BRANCH=main` (upstream repo) → `UPSTREAM_LOCAL_BRANCH=main` (your repo)
115115
- **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)
116+
- **Development Workflow**: `UPSTREAM_BRANCH=main` (upstream repo) → `UPSTREAM_LOCAL_BRANCH=dev` (your repo)
117+
- **Feature Branch Workflow**: `UPSTREAM_BRANCH=develop` (upstream repo) → `UPSTREAM_LOCAL_BRANCH=develop` (your repo)
118+
119+
### Common Branch Naming Conventions
120+
121+
Most projects use these branch naming patterns:
122+
123+
- **`dev`** - Development branch (most common in many projects)
124+
- **`master`** - Traditional main branch (common in older projects)
125+
- **`main`** - Modern main branch (newer projects, GitHub default)
126+
- **`develop`** - GitFlow development branch
127+
- **`staging`** - Staging environment branch
128+
129+
**Setup defaults to `dev`** as it's the most common development branch convention.
117130

118131
### Publish Configuration
119132

@@ -159,7 +172,7 @@ Add these to your `.env` file:
159172
# Upstream repository configuration
160173
UPSTREAM_URL=https://github.com/your-upstream/repo.git
161174
UPSTREAM_BRANCH=main # Branch in upstream repo to pull from
162-
UPSTREAM_LOCAL_BRANCH=main # Your main project branch (PRs created against this)
175+
UPSTREAM_LOCAL_BRANCH=dev # Your main project branch (PRs created against this)
163176
UPSTREAM_STRATEGY=merge
164177
UPSTREAM_COMMIT_MESSAGE="chore(upstream): sync from upstream"
165178
UPSTREAM_ALLOW_UNRELATED=true

src/Console/Commands/UpstreamCheckCommand.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public function handle(): int
7878
// Get upstream commit
7979
$upstreamCommit = $git->run(['rev-parse', "$remoteName/$upstreamBranch"]);
8080
$this->line('📍 Latest upstream commit: <info>'.mb_substr($upstreamCommit, 0, 8).'</info>');
81+
82+
// Show more detailed commit information
83+
$this->showCommitDetails($git, $localCommit, $upstreamCommit);
8184

8285
// Check if we're behind
8386
$isBehind = $this->isBehind($git, $localBranch, "$remoteName/$upstreamBranch");
@@ -93,11 +96,14 @@ public function handle(): int
9396
$this->line('💡 To pull the updates, run:');
9497
$this->line(' <info>php artisan laravelplus:update</info> (creates PR by default)');
9598
$this->line(' <info>php artisan laravelplus:update --direct</info> (to apply directly)');
99+
$this->newLine();
100+
$this->line("🔗 PR will sync from upstream commit: <info>".mb_substr($upstreamCommit, 0, 8)."</info>");
96101

97102
return self::SUCCESS;
98103
}
99104
$this->newLine();
100105
$this->info('✅ You are up to date! No updates available.');
106+
$this->line("📋 Last sync was from upstream commit: <info>".mb_substr($upstreamCommit, 0, 8)."</info>");
101107

102108
return self::SUCCESS;
103109

@@ -218,4 +224,30 @@ private function applyDefaultPreset(array $cfg): array
218224

219225
return $cfg;
220226
}
227+
228+
private function showCommitDetails(VersionControl $git, string $localCommit, string $upstreamCommit): void
229+
{
230+
try {
231+
// Get commit messages
232+
$localMessage = $git->run(['log', '--format=%s', '-n', '1', $localCommit]);
233+
$upstreamMessage = $git->run(['log', '--format=%s', '-n', '1', $upstreamCommit]);
234+
235+
// Get commit dates
236+
$localDate = $git->run(['log', '--format=%ci', '-n', '1', $localCommit]);
237+
$upstreamDate = $git->run(['log', '--format=%ci', '-n', '1', $upstreamCommit]);
238+
239+
$this->newLine();
240+
$this->line('📝 <comment>Commit Details:</comment>');
241+
$this->line(" Local: <info>".mb_substr($localCommit, 0, 8)."</info> - ".mb_trim($localMessage));
242+
$this->line(" Upstream: <info>".mb_substr($upstreamCommit, 0, 8)."</info> - ".mb_trim($upstreamMessage));
243+
244+
// Show dates
245+
$this->line('📅 <comment>Last Updated:</comment>');
246+
$this->line(" Local: <info>".date('Y-m-d H:i:s', strtotime($localDate))."</info>");
247+
$this->line(" Upstream: <info>".date('Y-m-d H:i:s', strtotime($upstreamDate))."</info>");
248+
249+
} catch (Throwable) {
250+
// If we can't get commit details, just continue silently
251+
}
252+
}
221253
}

src/Console/Commands/UpstreamSetupCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ private function setupPreset(string $preset): int
9494
// Ask for local branch (what branch to create PRs against)
9595
$localBranch = $this->text(
9696
'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)'
97+
default: 'dev',
98+
placeholder: 'e.g., master, dev, main (your main project branch)'
9999
);
100100

101101
// Update .env file
@@ -145,8 +145,8 @@ private function setupCustom(): int
145145

146146
$localBranch = $this->text(
147147
'Which local branch should receive the updates? (PRs will be created against this branch)',
148-
default: 'main',
149-
placeholder: 'e.g., main, master, develop (your main project branch)'
148+
default: 'dev',
149+
placeholder: 'e.g., master, dev, main (your main project branch)'
150150
);
151151

152152
$this->info('Setting up upstream sync for custom repository...');

0 commit comments

Comments
 (0)