Cleanup all directories on output, remove src/internal/unsafeheader

This commit is contained in:
DataHoarder 2024-05-10 06:11:18 +02:00
parent f7cfb63d3b
commit 7a7aaa3c1e
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk

31
main.go
View file

@ -29,7 +29,7 @@ func main() {
}
defer os.RemoveAll(tmpDir)
repo, err := git.PlainClone(tmpDir, false, &git.CloneOptions{
_, err = git.PlainClone(tmpDir, false, &git.CloneOptions{
URL: *repositoryUrl,
ReferenceName: plumbing.NewTagReferenceName(*repositoryRef),
SingleBranch: true,
@ -40,7 +40,7 @@ func main() {
})
if errors.Is(err, git.NoMatchingRefSpecError{}) {
//retry with branch name instead
repo, err = git.PlainClone(tmpDir, false, &git.CloneOptions{
_, err = git.PlainClone(tmpDir, false, &git.CloneOptions{
URL: *repositoryUrl,
ReferenceName: plumbing.NewBranchReferenceName(*repositoryRef),
SingleBranch: true,
@ -53,18 +53,26 @@ func main() {
if err != nil {
panic(err)
}
_ = repo
err = os.MkdirAll(*outputDirectory, 0755)
if err != nil {
panic(err)
}
dirList, err := os.ReadDir(*outputDirectory)
if err != nil {
panic(err)
}
// Cleanup directories from source
for _, cleanDir := range []string{
"abi", "asm", "bisect", "buildcfg", "dwarf", "goarch",
"obj", "objabi", "src", "sys", "bio", "goobj", "unsafeheader",
} {
err = os.RemoveAll(path.Join(*outputDirectory, cleanDir))
if err != nil {
panic(err)
for _, d := range dirList {
if d.IsDir() {
err = os.RemoveAll(path.Join(*outputDirectory, d.Name()))
if err != nil {
panic(err)
}
}
}
type targets [2]string
@ -78,7 +86,6 @@ func main() {
{"src/cmd/internal/dwarf", "dwarf"},
{"src/cmd/internal/src", "src"},
{"src/cmd/internal/sys", "sys"},
{"src/internal/unsafeheader", "unsafeheader"},
{"src/internal/abi", "abi"},
{"src/internal/goarch", "goarch"},
{"src/internal/bisect", "bisect"},