Skip to content

Commit 424ec5f

Browse files
🩹 [Patch]: Simplify branch naming and commit message for font updates (#71)
## Description This pull request includes updates to the `scripts/Update-FontsData.ps1` script to streamline naming conventions and improve clarity in commit messages and pull request creation. The changes focus on simplifying branch naming, standardizing commit messages, and refining pull request titles and descriptions. ### Updates to naming conventions: * Updated the branch naming pattern from `auto-update-font-$timeStamp` to `auto-update-$timeStamp` for consistency and simplicity. (`[scripts/Update-FontsData.ps1L52-R52](diffhunk://#diff-69d235ffacf154789a70d5e00a557ee83393c256cd9431a8b7be57cc41c3ad89L52-R52)`) ### Improvements to commit and PR messages: * Modified the commit message from "Update-FontsData via script on $timeStamp" to "Update FontsData.json" for better clarity and alignment with the changes being committed. (`[scripts/Update-FontsData.ps1L96-R96](diffhunk://#diff-69d235ffacf154789a70d5e00a557ee83393c256cd9431a8b7be57cc41c3ad89L96-R96)`) * Simplified the pull request title and body by removing references to "Google Fonts" and using more generic phrasing. The title now reads "Auto-Update $timeStamp," and the body specifies updates to "the latest metadata" instead of "Google Fonts metadata." (`[scripts/Update-FontsData.ps1L117-R127](diffhunk://#diff-69d235ffacf154789a70d5e00a557ee83393c256cd9431a8b7be57cc41c3ad89L117-R127)`) ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas
1 parent eea95a6 commit 424ec5f

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

scripts/Update-FontsData.ps1

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
}
3434
}
3535

36+
Install-PSResource -Repository PSGallery -TrustRepository -Name 'Json'
37+
3638
Connect-GitHubApp -Organization 'PSModule' -Default
3739
$repo = Get-GitHubRepository -Owner 'PSModule' -Name 'GoogleFonts'
3840

@@ -49,7 +51,7 @@ LogGroup 'Checkout' {
4951
$timeStamp = Get-Date -Format 'yyyyMMdd-HHmmss'
5052
if ($currentBranch -eq $defaultBranch) {
5153
# Running on main/default branch - create new branch
52-
$targetBranch = "auto-update-font-$timeStamp"
54+
$targetBranch = "auto-update-$timeStamp"
5355
Write-Output "Running on default branch. Creating new branch: $targetBranch"
5456
Run git checkout -b $targetBranch
5557
} else {
@@ -82,7 +84,7 @@ LogGroup 'Getting latest fonts' {
8284
$parentFolder = Split-Path -Path $PSScriptRoot -Parent
8385
$filePath = Join-Path -Path $parentFolder -ChildPath 'src\FontsData.json'
8486
$null = New-Item -Path $filePath -ItemType File -Force
85-
$fonts | ConvertTo-Json | Set-Content -Path $filePath -Force
87+
$fonts | ConvertTo-Json | Format-Json -IndentationType Spaces -IndentationSize 4 | Set-Content -Path $filePath -Force
8688
}
8789

8890
$changes = Run git status --porcelain
@@ -93,7 +95,7 @@ if ([string]::IsNullOrWhiteSpace($changes)) {
9395
}
9496
LogGroup 'Get changes' {
9597
Run git add .
96-
Run git commit -m "Update-FontsData via script on $timeStamp"
98+
Run git commit -m 'Update FontsData.json'
9799
Write-Output 'Changes in this commit:'
98100
$changes = Run git diff HEAD~1 HEAD -- src/FontsData.json
99101
Write-Output $changes
@@ -114,20 +116,17 @@ $changes
114116
}
115117

116118
LogGroup 'Process changes' {
117-
# Push behavior depends on branch type
118119
if ($targetBranch -eq $currentBranch -and $currentBranch -ne $defaultBranch) {
119-
# Push to existing branch
120120
Run git push origin $targetBranch
121121
Write-Output "Changes committed and pushed to existing branch: $targetBranch"
122122
} else {
123-
# Push new branch and create PR
124123
Run git push --set-upstream origin $targetBranch
125124

126125
Run gh pr create `
127126
--base $defaultBranch `
128127
--head $targetBranch `
129-
--title "Auto-Update: Google Fonts Data ($timeStamp)" `
130-
--body 'This PR updates FontsData.json with the latest Google Fonts metadata.'
128+
--title "Auto-Update $timeStamp" `
129+
--body 'This PR updates FontsData.json with the latest metadata.'
131130

132131
Write-Output "Changes detected and PR opened for branch: $targetBranch"
133132
}

src/FontsData.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"Variant": "regular",
1515
"URL": "https://fonts.gstatic.com/s/adlamdisplay/v1/KFOhCnGXkPOLlhx6jD8_b1ZECsHYkYBPY3o.ttf"
1616
},
17+
{
18+
"Name": "Test",
19+
"Variant": "regular",
20+
"URL": "https://fonts.gstatic.com/s/test/v1/abcd1234.ttf"
21+
},
1722
{
1823
"Name": "AR One Sans",
1924
"Variant": "regular",

0 commit comments

Comments
 (0)