Skip to content

Commit

Permalink
Collect .changes file in directory hiearchy. #71
Browse files Browse the repository at this point in the history
  • Loading branch information
smira committed Mar 15, 2015
1 parent 615a5ee commit 925882b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions deb/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package deb

import (
"fmt"
"github.com/smira/aptly/aptly"
"github.com/smira/aptly/utils"
"io/ioutil"
"os"
"path/filepath"
"sort"
"strings"
)

// Changes is a result of .changes file parsing
Expand Down Expand Up @@ -145,3 +148,37 @@ func (c *Changes) Cleanup() error {

return os.RemoveAll(c.TempDir)
}

// CollectChangesFiles walks filesystem collecting all .changes files
func CollectChangesFiles(locations []string, reporter aptly.ResultReporter) (changesFiles, failedFiles []string) {
for _, location := range locations {
info, err2 := os.Stat(location)
if err2 != nil {
reporter.Warning("Unable to process %s: %s", location, err2)
failedFiles = append(failedFiles, location)
continue
}
if info.IsDir() {
err2 = filepath.Walk(location, func(path string, info os.FileInfo, err3 error) error {
if err3 != nil {
return err3
}
if info.IsDir() {
return nil
}

if strings.HasSuffix(info.Name(), ".changes") {
changesFiles = append(changesFiles, path)
}

return nil
})
} else if strings.HasSuffix(info.Name(), ".changes") {
changesFiles = append(changesFiles, location)
}
}

sort.Strings(changesFiles)

return
}

0 comments on commit 925882b

Please sign in to comment.