Skip to content

Commit f94c626

Browse files
n-peugnetottok
authored andcommitted
estimate: add a link to FTP masters website for NEW packages
By the way, refactor just a little bit the generation of the estimate output.
1 parent 066571e commit f94c626

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

estimate.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ func trackerLink(pkg string) string {
142142
return fmt.Sprintf("\033]8;;https://tracker.debian.org/pkg/%[1]s\033\\%[1]s\033]8;;\033\\", pkg)
143143
}
144144

145+
// newPackageLine generates a line for packages in NEW, including an OSC 8
146+
// hyperlink to the FTP masters website for the given Debian package.
147+
func newPackageLine(indent int, mod, debpkg, version string) string {
148+
const format = "%s\033[36m%s (\033]8;;https://ftp-master.debian.org/new/%s_%s.html\033\\in NEW\033]8;;\033\\)\033[0m"
149+
return fmt.Sprintf(format, strings.Repeat(" ", indent), mod, debpkg, version)
150+
}
151+
145152
func estimate(importpath, revision string) error {
146153
removeTemp := func(path string) {
147154
if err := forceRemoveAll(path); err != nil {
@@ -267,8 +274,8 @@ func estimate(importpath, revision string) error {
267274
return
268275
}
269276
if pkg, ok := golangBinaries[mod]; ok {
270-
if _, ok := sourcesInNew[pkg.source]; ok {
271-
line := fmt.Sprintf("%s\033[36m%s (in NEW)\033[0m", strings.Repeat(" ", indent), mod)
277+
if version, ok := sourcesInNew[pkg.source]; ok {
278+
line := newPackageLine(indent, mod, pkg.source, version)
272279
lines = append(lines, line)
273280
}
274281
return // already packaged in Debian
@@ -291,8 +298,8 @@ func estimate(importpath, revision string) error {
291298
} else {
292299
log.Printf("%s is v%d in Debian (%s)", mod, v, trackerLink(pkg.source))
293300
}
294-
if _, ok := sourcesInNew[pkg.source]; ok {
295-
line := fmt.Sprintf("%s\033[36m%s (in NEW)\033[0m", strings.Repeat(" ", indent), mod)
301+
if version, ok := sourcesInNew[pkg.source]; ok {
302+
line := newPackageLine(indent, mod, pkg.source, version)
296303
lines = append(lines, line)
297304
}
298305
return
@@ -304,8 +311,8 @@ func estimate(importpath, revision string) error {
304311
// Log info to indicate that it is an approximate match
305312
// but consider that it is packaged and skip the children.
306313
log.Printf("%s is packaged as %s in Debian (%s)", mod, repoRoot, trackerLink(pkg.source))
307-
if _, ok := sourcesInNew[pkg.source]; ok {
308-
line := fmt.Sprintf("%s\033[36m%s (in NEW)\033[0m", strings.Repeat(" ", indent), mod)
314+
if version, ok := sourcesInNew[pkg.source]; ok {
315+
line := newPackageLine(indent, mod, pkg.source, version)
309316
lines = append(lines, line)
310317
}
311318
return

0 commit comments

Comments
 (0)