blob: 4047e252781f13e17806011f84409fac5562532c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package main
import (
"path"
)
func filename2branchname(filename string) string {
// Let us write the .SRCINFO files.
switch path.Base(filename) {
case ".AURINFO", ".SRCINFO":
return ""
}
// There is nothing logical or universally true about the
// remainder of this function. It is simply a set of
// heuristics that works on the packages.git and community.git
// svn2git repos.
//
// The more truthful method would be to use PKGBUILD as a
// signal that a directory is a branch. However, that would
// be fairly expensive.
branchname := path.Dir(filename)
if branchname == "xalan-c/repos/extra-i686" {
// xalan-c has only ever been in community, not extra.
// Arch has now dropped i686, so this won't happen in
// the future either.
return ""
}
// This blackliast assumes that no package named one of those
// strings will ever exist.
loop:
for {
switch path.Base(branchname) {
case "log", "src": // packages.git
branchname = path.Dir(branchname)
case "CVS", "examples": // community.git
branchname = path.Dir(branchname)
case "repos":
return ""
default:
break loop
}
}
// A branch must contain a "/"
if path.Dir(branchname) == "." {
return ""
}
return branchname
}
|