Skip to content

Commit 418d7dd

Browse files
committed
chore: improve pr bodies
1 parent c475be2 commit 418d7dd

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/buddy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ export class Buddy {
131131
this.config.repository.name,
132132
)
133133

134-
// Initialize PR generator
135-
const prGenerator = new PullRequestGenerator()
134+
// Initialize PR generator with config
135+
const prGenerator = new PullRequestGenerator(this.config)
136136

137137
// Process each group
138138
for (const group of scanResult.groups) {

src/pr/pr-generator.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type { PackageInfo, ReleaseNote } from '../services/release-notes-fetcher'
2-
import type { PullRequest, UpdateGroup } from '../types'
2+
import type { BuddyBotConfig, PullRequest, UpdateGroup } from '../types'
33
import { ReleaseNotesFetcher } from '../services/release-notes-fetcher'
44

55
export class PullRequestGenerator {
66
private releaseNotesFetcher = new ReleaseNotesFetcher()
77

8+
constructor(private readonly config?: BuddyBotConfig) {}
9+
810
/**
911
* Generate pull requests for update groups
1012
*/
@@ -451,7 +453,10 @@ export class PullRequestGenerator {
451453
// Add file reference with link to the dependency file
452454
if (update.file) {
453455
const fileName = update.file.split('/').pop() || update.file
454-
body += `📁 **File**: [\`${fileName}\`](https://github.com/${this.config.repository.owner}/${this.config.repository.name}/blob/main/${update.file})\n\n`
456+
const fileCell = this.config?.repository?.owner && this.config?.repository?.name
457+
? `📁 **File**: [\`${fileName}\`](https://github.com/${this.config.repository.owner}/${this.config.repository.name}/blob/main/${update.file})\n\n`
458+
: `📁 **File**: \`${fileName}\`\n\n`
459+
body += fileCell
455460
}
456461

457462
// Add appropriate links based on package type
@@ -533,9 +538,10 @@ export class PullRequestGenerator {
533538
body += `📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).\n\n`
534539
body += `🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.\n\n`
535540
body += `♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.\n\n`
536-
body += `🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.\n\n`
541+
const ignoreText = group.updates.length === 1 ? 'this update again' : 'these updates again'
542+
body += `🔕 **Ignore**: Close this PR and you won't be reminded about ${ignoreText}.\n\n`
537543
body += `---\n\n`
538-
body += ` - [ ] <!-- rebase-check -->If you want to update/retry this PR, check this box\n\n`
544+
body += ` - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box\n\n`
539545
body += `---\n\n`
540546
body += `This PR was generated by [Buddy](https://github.com/stacksjs/buddy-bot) 🤖`
541547

0 commit comments

Comments
 (0)