Skip to content

Commit e6d16d4

Browse files
committed
Add a script to generate the list of releases
The idea is to map the current Git for Windows' Pacman repository to a set of releases in https://github.com/git-for-windows/pacman-repo. Sadly, this set of releases can _not_ serve as the new Pacman repository for Git for Windows, because Pacman repositories have a flat directory structure: the database file needs to live in the same "directory" as the packages. In other words, if the database lives in https://github.com/git-for-windows/pacman-repo/releases/download/latest-git-for-windows.db then the packages need to live in the same GitHub release. I do not want that, though, as it would be wasteful to replicate the package files every time the Pacman repository is updated, as opposed to uploading only the files for the updated package to the releases. However, for transparency reasons, it is a good idea to upload the package files (even historical versions) to GitHub releases. That allows investigators (or: interested Git for Windows users) to inspect what package versions had been used in Git for Windows at various stages. To prepare for that, here is a node.js script that parses the just-downloaded JSON reflecting what has been uploaded at various times to Git for Windows' Pacman repository. It then outputs a list of timestamps and sets of files that should be turned into GitHub releases and assets. This will finally disentangle Git for Windows' Pacman repository from my personal Azure account, as it should have been in the first place. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent c121a5f commit e6d16d4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

make-list.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env node
2+
3+
module.exports = () => {
4+
const fs = require("fs")
5+
l = ["i686", "x86-64", "aarch64", "sources"]
6+
.reduce((a, e) => {
7+
return [
8+
...a,
9+
...JSON.parse(fs.readFileSync(`${e}-list.txt`))
10+
]
11+
}, [])
12+
13+
let lastUpdate = -1
14+
return l.map(e => {
15+
return {
16+
name: `${e.container}/${e.name}`,
17+
date: e.properties.lastModified,
18+
size: e.properties.contentLength
19+
}
20+
})
21+
.sort((a, b) => Date.parse(a.date) - Date.parse(b.date))
22+
.reduce((a, e) => {
23+
let last = a.pop() || { date: e.date, start: e.date, names: [], totalSize: 0 }
24+
if (Date.parse(last.date) + 10 * 60 * 1000 < Date.parse(e.date)) {
25+
a.push(last)
26+
last = { start: e.date, names: [], totalSize: 0 }
27+
}
28+
last.date = e.date
29+
last.names.push(e.name)
30+
last.totalSize += e.size
31+
a.push(last)
32+
return a
33+
}, [])
34+
.map(e => {
35+
const secondsBetweenUpdates = lastUpdate < 0 ? undefined : (Date.parse(e.date) - lastUpdate) / 1000
36+
lastUpdate = Date.parse(e.date)
37+
return {
38+
...e,
39+
duration: (Date.parse(e.date) - Date.parse(e.start)) / 1000,
40+
secondsBetweenUpdates,
41+
date: new Date(e.date)
42+
}
43+
})
44+
}
45+
46+
if (require.main === module) {
47+
console.log(JSON.stringify(module.exports(), null, 2))
48+
}

0 commit comments

Comments
 (0)