Skip to content

Commit 9b06911

Browse files
authored
Merge pull request #1 from git-for-windows/backfill-missing-rc-versions
Backfill missing `-rc` versions
2 parents c19ec36 + 31ab79a commit 9b06911

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

add-entry.js

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,56 @@ const main = async (...args) => {
2323
const addURL = url => {
2424
const fileName = url.replace(/.*\//, '')
2525
const match = fileName.match(fileNameRegex)
26-
if (!match) throw new Error(`Cannot parse URL: ${url}`)
26+
if (!match) throw new Error(`Cannot parse URL: ${url} (fileName: ${fileName})`)
2727
else if (match[1]) urls.installers.push({ url, cpu: cpus[match[2]] })
2828
else if (match[3]) urls.portableGits.push({ url, cpu: cpus[match[4]] })
2929
else if (match[5]) urls.busyBoxMinGits.push({ url, cpu: cpus[match[6]] })
3030
else if (match[7]) urls.minGits.push({ url, cpu: cpus[match[8]] })
3131
else throw new Error(`Cannot parse URL: ${url}`)
3232
}
3333

34+
let mode = 'append-to-top'
3435
let date
3536
let commit
3637
while (args.length > 0) {
3738
const arg = args.shift()
3839
if (arg.startsWith('--date=')) date = arg.replace(/.*?=/, '')
3940
else if (arg.startsWith('--commit=')) commit = arg.replace(/.*?=/, '')
4041
else if (arg.startsWith('https://')) addURL(arg)
41-
else {
42+
else if (arg.startsWith('--backfill-release=')) {
43+
if (args.length) throw new Error(`--backfill-release cannot be combined with other arguments!`)
44+
const tagName = arg.replace(/.*?=/, '')
45+
.replace(/^https:\/\/github\.com\/git-for-windows\/git\/releases\/tag\//, '')
46+
if (!tagName.match(/^v[1-9][0-9]*(\.\d+){2}(-rc\d+)?\.windows\.\d+$/)) {
47+
throw new Error(`Unexpected tag format: '${tagName}'!`)
48+
}
49+
50+
const gh = async (path) =>
51+
(await fetch(`https://api.github.com/repos/git-for-windows/git/${path}`)).json()
52+
const { object: { sha: tagSHA } } = await gh(`git/ref/tags/${tagName}`)
53+
const { object: { sha: commitSHA } } = await gh(`git/tags/${tagSHA}`)
54+
commit = commitSHA
55+
const { committer: { date: commitDate } } = await gh(`git/commits/${commitSHA}`)
56+
date = (new Date(commitDate)).toLocaleString('en-US', {
57+
weekday: 'short',
58+
month: 'short',
59+
day: 'numeric',
60+
year: 'numeric',
61+
hour: '2-digit',
62+
hourCycle: "h24",
63+
minute: '2-digit',
64+
second: '2-digit',
65+
timeZoneName: 'longOffset',
66+
timeZone: "Etc/UTC"
67+
})
68+
69+
const { assets } = await gh(`releases/tags/${tagName}`)
70+
assets.forEach(asset => {
71+
if (!asset.name.endsWith('.tar.bz2') && !asset.name.startsWith('pdbs')) addURL(asset.browser_download_url)
72+
})
73+
74+
mode = 'insert-by-date'
75+
} else {
4276
throw new Error(`Unhandled argument '${arg}`)
4377
}
4478
}
@@ -87,7 +121,12 @@ const main = async (...args) => {
87121
'</ul>'
88122
].join('')
89123

90-
sections[1] = `${insert}\n\n${sections[1]}`
124+
let index = 1
125+
if (mode === 'insert-by-date') {
126+
while (index + 2 < sections.length && insert.localeCompare(sections[index]) < 0) index += 2
127+
} else if (mode !== 'append-to-top') throw new Error(`Unhandled mode: '${mode}'`)
128+
sections[index] = `${insert}\n\n${sections[index]}`
129+
91130
fs.writeFileSync('index.html', sections.join(''))
92131
}
93132

index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ <h2 id="2025-03-10T14:05:13.000Z"><a class="anchor" href="#2025-03-10T14:05:13.0
4646
<li>MinGit (BusyBox): <a href="https://github.com/git-for-windows/git-snapshots/releases/download/prerelease-2.49.0-rc1.windows.1-2-g511a07b339-20250310140624/MinGit-prerelease-2.49.0-rc1.windows.1-2-g511a07b339-20250310140624-busybox-64-bit.zip">x64 (64-bit)</a> and <a href="https://github.com/git-for-windows/git-snapshots/releases/download/prerelease-2.49.0-rc1.windows.1-2-g511a07b339-20250310140624/MinGit-prerelease-2.49.0-rc1.windows.1-2-g511a07b339-20250310140624-busybox-32-bit.zip">x86 (32-bit)</a>.</li>
4747
</ul>
4848

49+
<h2 id="2025-03-05T12:01:38.000Z"><a class="anchor" href="#2025-03-05T12:01:38.000Z">&#128279;</a>Wed, Mar 5, 2025, 12:01:38 GMT<br />(commit <a href="https://github.com/git-for-windows/git/commit/31963038164d1a2d78dc46225f8441e8c0fb07a8">31963038164d1a2d78dc46225f8441e8c0fb07a8</a>)</h2>
50+
51+
<ul>
52+
<li>Git for Windows installer: <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/Git-2.49.0-rc1-64-bit.exe">x64 (64-bit)</a> and <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/Git-2.49.0-rc1-arm64.exe">ARM64</a>.</li>
53+
<li>Portable Git (self-extracting <tt>.7z</tt> archive): <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/PortableGit-2.49.0-rc1-64-bit.7z.exe">x64 (64-bit)</a> and <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/PortableGit-2.49.0-rc1-arm64.7z.exe">ARM64</a>.</li>
54+
<li>MinGit: <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/MinGit-2.49.0-rc1-64-bit.zip">x64 (64-bit)</a>, <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/MinGit-2.49.0-rc1-arm64.zip">ARM64</a> and <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/MinGit-2.49.0-rc1-32-bit.zip">x86 (32-bit)</a>.</li>
55+
<li>MinGit (BusyBox): <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/MinGit-2.49.0-rc1-busybox-64-bit.zip">x64 (64-bit)</a> and <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/MinGit-2.49.0-rc1-busybox-32-bit.zip">x86 (32-bit)</a>.</li>
56+
</ul>
57+
4958
<h2 id="2025-03-04T18:54:35.000Z"><a class="anchor" href="#2025-03-04T18:54:35.000Z">&#128279;</a>Tue, Mar 4, 2025, 06:54:35 PM GMT<br />(commit <a href="https://github.com/git-for-windows/git/commit/1424e2777e22d3195d9c9926ec3d1909bc0dc1e1">1424e2777e22d3195d9c9926ec3d1909bc0dc1e1</a>)</h2>
5059

5160
<ul>
@@ -55,6 +64,15 @@ <h2 id="2025-03-04T18:54:35.000Z"><a class="anchor" href="#2025-03-04T18:54:35.0
5564
<li>MinGit (BusyBox): <a href="https://github.com/git-for-windows/git-snapshots/releases/download/prerelease-2.49.0-rc0.windows.1-2-g1424e2777e-20250304185532/MinGit-prerelease-2.49.0-rc0.windows.1-2-g1424e2777e-20250304185532-busybox-64-bit.zip">x64 (64-bit)</a> and <a href="https://github.com/git-for-windows/git-snapshots/releases/download/prerelease-2.49.0-rc0.windows.1-2-g1424e2777e-20250304185532/MinGit-prerelease-2.49.0-rc0.windows.1-2-g1424e2777e-20250304185532-busybox-32-bit.zip">x86 (32-bit)</a>.</li>
5665
</ul>
5766

67+
<h2 id="2025-02-26T20:19:31.000Z"><a class="anchor" href="#2025-02-26T20:19:31.000Z">&#128279;</a>Wed, Feb 26, 2025, 20:19:31 GMT<br />(commit <a href="https://github.com/git-for-windows/git/commit/d20d8cdf84017e3fcf0081f4c2f9ef49647afb08">d20d8cdf84017e3fcf0081f4c2f9ef49647afb08</a>)</h2>
68+
69+
<ul>
70+
<li>Git for Windows installer: <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/Git-2.49.0-rc0-64-bit.exe">x64 (64-bit)</a> and <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/Git-2.49.0-rc0-arm64.exe">ARM64</a>.</li>
71+
<li>Portable Git (self-extracting <tt>.7z</tt> archive): <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/PortableGit-2.49.0-rc0-64-bit.7z.exe">x64 (64-bit)</a> and <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/PortableGit-2.49.0-rc0-arm64.7z.exe">ARM64</a>.</li>
72+
<li>MinGit: <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/MinGit-2.49.0-rc0-64-bit.zip">x64 (64-bit)</a>, <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/MinGit-2.49.0-rc0-arm64.zip">ARM64</a> and <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/MinGit-2.49.0-rc0-32-bit.zip">x86 (32-bit)</a>.</li>
73+
<li>MinGit (BusyBox): <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/MinGit-2.49.0-rc0-busybox-64-bit.zip">x64 (64-bit)</a> and <a href="https://github.com/git-for-windows/git/releases/download/v2.49.0-rc0.windows.1/MinGit-2.49.0-rc0-busybox-32-bit.zip">x86 (32-bit)</a>.</li>
74+
</ul>
75+
5876
<h2 id="2025-02-26T18:35:33.000Z"><a class="anchor" href="#2025-02-26T18:35:33.000Z">&#128279;</a>Wed, Feb 26, 2025, 06:35:33 PM GMT<br />(commit <a href="https://github.com/git-for-windows/git/commit/ba6e4aaec47e8695bd59117967d9b18b1e477686">ba6e4aaec47e8695bd59117967d9b18b1e477686</a>)</h2>
5977

6078
<ul>

0 commit comments

Comments
 (0)