Skip to content

Commit bcca7c5

Browse files
committed
chore: minor updates
1 parent ad9b061 commit bcca7c5

File tree

10 files changed

+86
-35
lines changed

10 files changed

+86
-35
lines changed

.github/workflows/buddy-check.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Buddy Check
33
on:
44
schedule:
55
- cron: '*/1 * * * *' # Check every 1 minute (GitHub Actions has rate limits for frequent schedules)
6+
67
workflow_dispatch: # Manual trigger
78
inputs:
89
dry_run:
@@ -56,13 +57,10 @@ jobs:
5657
if: ${{ hashFiles('composer.json') != '' }}
5758
run: composer install --prefer-dist --optimize-autoloader
5859

59-
- name: Build buddy-bot
60-
run: bun run build
61-
6260
- name: Configure Git
6361
run: |
64-
git config --global user.name "buddy-bot[bot]"
65-
git config --global user.email "buddy-bot[bot]@users.noreply.github.com"
62+
git config --global user.name "github-actions[bot]"
63+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
6664
6765
- name: Check token permissions
6866
run: |

.github/workflows/buddy-update.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Buddy Update
33
on:
44
schedule:
55
- cron: '0 */2 * * *' # Every 2 hours for testing (more reasonable for testing)
6+
67
workflow_dispatch: # Manual triggering for development
78
inputs:
89
strategy:
@@ -77,13 +78,10 @@ jobs:
7778
if: ${{ hashFiles('composer.json') != '' }}
7879
run: composer install --prefer-dist --optimize-autoloader
7980

80-
- name: Build buddy-bot
81-
run: bun run build
82-
8381
- name: Configure Git
8482
run: |
85-
git config --global user.name "buddy-bot[bot]"
86-
git config --global user.email "buddy-bot[bot]@users.noreply.github.com"
83+
git config --global user.name "github-actions[bot]"
84+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
8785
8886
- name: Verify Composer setup
8987
run: |

build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ await Bun.build({
77
outdir: './dist',
88
format: 'esm',
99
target: 'bun',
10-
minify: true,
10+
minify: false,
1111
splitting: true,
1212
plugins: [dts()],
1313
})

docs/features/rebase.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ During rebase, Buddy Bot updates:
180180
```yaml
181181
- name: Configure Git
182182
run: |
183-
git config --global user.name "buddy-bot[bot]"
184-
git config --global user.email "buddy-bot[bot]@users.noreply.github.com"
183+
git config --global user.name "github-actions[bot]"
184+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
185185
```
186186

187187
#### 3. No PRs Found

src/buddy.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,14 @@ export class Buddy {
226226
// Update package.json with new versions
227227
const packageJsonUpdates = await this.generateAllFileUpdates(group.updates)
228228

229+
// Check if we have any file changes to commit
230+
if (packageJsonUpdates.length === 0) {
231+
this.logger.warn(`ℹ️ No file changes generated for group ${group.name}, skipping PR creation`)
232+
continue
233+
}
234+
235+
this.logger.info(`📝 Generated ${packageJsonUpdates.length} file changes for ${group.name}`)
236+
229237
// Commit changes
230238
await gitProvider.commitChanges(branchName, group.title, packageJsonUpdates)
231239

@@ -754,7 +762,7 @@ export class Buddy {
754762

755763
// Add additional contextual labels
756764
if (group.updates.length > 5) {
757-
labels.add('bulk-update')
765+
labels.add('dependencies') // Use standard dependencies label instead of bulk-update
758766
}
759767

760768
// Add security label if any package might be security related

src/pr/pr-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class PullRequestGenerator {
2626
url: '',
2727
createdAt: new Date(),
2828
updatedAt: new Date(),
29-
author: 'buddy-bot',
29+
author: 'github-actions[bot]',
3030
reviewers: [],
3131
assignees: [],
3232
labels: ['dependencies', 'automated'],

src/registry/registry-client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ export class RegistryClient {
359359
// Get the actual version from package.json (strip caret, tilde, etc.)
360360
const cleanVersion = this.cleanVersionRange(packageJsonVersion)
361361

362+
// Skip workspace: versions as they're not meant for semver comparison
363+
if (!cleanVersion) {
364+
continue
365+
}
366+
362367
// Get latest version from registry
363368
const latestVersion = await this.getLatestVersion(packageName)
364369
if (!latestVersion)
@@ -395,6 +400,11 @@ export class RegistryClient {
395400
* Clean version range to get the base version (remove ^, ~, etc.)
396401
*/
397402
private cleanVersionRange(version: string): string {
403+
// Handle workspace: protocol - skip these as they're not meant for semver comparison
404+
if (version.startsWith('workspace:')) {
405+
return null
406+
}
407+
398408
// Remove common range indicators
399409
return version.replace(/^[\^~>=<]/, '').trim()
400410
}

src/setup.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,16 +1259,6 @@ jobs:
12591259
with:
12601260
bun-version: latest
12611261
${generateComposerSetupSteps()}
1262-
- name: Install dependencies
1263-
run: bun install
1264-
1265-
- name: Build buddy-bot
1266-
run: bun run build
1267-
1268-
- name: Configure Git
1269-
run: |
1270-
git config --global user.name "buddy-bot[bot]"
1271-
git config --global user.email "buddy-bot[bot]@users.noreply.github.com"
12721262
12731263
- name: Check for rebase requests
12741264
run: |
@@ -1379,8 +1369,8 @@ jobs:
13791369
13801370
- name: Configure Git
13811371
run: |
1382-
git config --global user.name "buddy-bot[bot]"
1383-
git config --global user.email "buddy-bot[bot]@users.noreply.github.com"
1372+
git config --global user.name "github-actions[bot]"
1373+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
13841374
13851375
- name: Verify Composer setup
13861376
run: |

src/utils/dependency-file-parser.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,19 @@ export async function generateDependencyFileUpdates(updates: PackageUpdate[]): P
144144
const currentContent = fs.readFileSync(filePath, 'utf-8')
145145
const updatedContent = await updateDependencyFile(filePath, currentContent, packageUpdates)
146146

147-
fileUpdates.push({
148-
path: filePath,
149-
content: updatedContent,
150-
type: 'update',
151-
})
147+
// Only add file update if content actually changed
148+
if (updatedContent !== currentContent) {
149+
fileUpdates.push({
150+
path: filePath,
151+
content: updatedContent,
152+
type: 'update',
153+
})
154+
console.log(`✅ Generated update for ${filePath} with ${packageUpdates.length} package changes`)
155+
} else {
156+
console.log(`ℹ️ No changes needed for ${filePath} - versions already up to date`)
157+
}
158+
} else {
159+
console.warn(`⚠️ Dependency file ${filePath} does not exist`)
152160
}
153161
}
154162
catch (error) {

src/utils/helpers.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,55 @@ export function generateBranchName(updates: PackageUpdate[], prefix = 'buddy'):
198198
}
199199
}
200200

201+
/**
202+
* Deduplicate updates by package name and version, keeping the most relevant file
203+
*/
204+
function deduplicateUpdates(updates: PackageUpdate[]): PackageUpdate[] {
205+
const uniqueUpdates = new Map<string, PackageUpdate>()
206+
207+
for (const update of updates) {
208+
const key = `${update.name}:${update.currentVersion}:${update.newVersion}`
209+
const existing = uniqueUpdates.get(key)
210+
211+
if (!existing) {
212+
uniqueUpdates.set(key, update)
213+
} else {
214+
// Keep the update with the most relevant file (prioritize package.json > composer.json > dependency files)
215+
const currentPriority = getFilePriority(update.file)
216+
const existingPriority = getFilePriority(existing.file)
217+
218+
if (currentPriority > existingPriority) {
219+
uniqueUpdates.set(key, update)
220+
}
221+
}
222+
}
223+
224+
return Array.from(uniqueUpdates.values())
225+
}
226+
227+
/**
228+
* Get file priority for deduplication (higher is more important)
229+
*/
230+
function getFilePriority(filePath: string): number {
231+
if (filePath === 'package.json') return 3
232+
if (filePath.endsWith('composer.json')) return 2
233+
if (filePath.includes('.github/workflows/')) return 1
234+
return 0 // dependency files like deps.yaml
235+
}
236+
201237
/**
202238
* Group updates based on configuration and type
203239
*/
204240
export function groupUpdates(updates: PackageUpdate[]): UpdateGroup[] {
205241
const groups: UpdateGroup[] = []
206242

243+
// Deduplicate updates by package name and version - keep the most relevant file
244+
const deduplicatedUpdates = deduplicateUpdates(updates)
245+
207246
// Group by update type
208-
const majorUpdates = updates.filter(u => u.updateType === 'major')
209-
const minorUpdates = updates.filter(u => u.updateType === 'minor')
210-
const patchUpdates = updates.filter(u => u.updateType === 'patch')
247+
const majorUpdates = deduplicatedUpdates.filter(u => u.updateType === 'major')
248+
const minorUpdates = deduplicatedUpdates.filter(u => u.updateType === 'minor')
249+
const patchUpdates = deduplicatedUpdates.filter(u => u.updateType === 'patch')
211250

212251
// Create individual PRs for each major update
213252
for (const majorUpdate of majorUpdates) {

0 commit comments

Comments
 (0)