Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions update-faq-security-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env node

/*
* Updates the FAQ's "Should I upgrade?" section to mention a new
* security-relevant Git for Windows version.
*
* Usage: node update-faq-security-version.js <display-version>
*
* Example: node update-faq-security-version.js '2.53.0(3)'
*/

const fs = require('fs')
const path = require('path')

const die = (msg) => {
process.stderr.write(msg + '\n')
process.exit(1)
}

const version = process.argv[2]
if (!version) die('Usage: node update-faq-security-version.js <display-version>')

const faqPath = path.join(__dirname, 'content', 'faq.md')
const faq = fs.readFileSync(faqPath, 'utf-8')

const marker = 'it is *highly* advisable to upgrade.'
const re = /^(If you have a version older than )\S+?(, it is \*highly\* advisable to upgrade\. A couple of Git versions came with important fixes to security-relevant vulnerabilities: )(.*)$/m
const match = faq.match(re)
if (!match) die('Could not find the security-versions line in content/faq.md')

const existingList = match[3]
if (existingList.startsWith(version + ',') || existingList.startsWith(version + ' ')) {
process.stderr.write(version + ' is already listed; nothing to do.\n')
process.exit(0)
}

const updated = faq.replace(re, `$1${version}$2${version}, ${existingList}`)
fs.writeFileSync(faqPath, updated)
process.stderr.write('Updated FAQ to recommend upgrading to at least ' + version + '\n')
Loading