Skip to content

Commit f9fe205

Browse files
committed
bundles: fix bundle parsing
A last-minute replacement of parsing to use scanner.Scan() changed the newline behavior of the line reading. This change allows us to actually parse bundle headers.
1 parent a7329d3 commit f9fe205

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/bundles/bundles.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func WriteBundleList(list BundleList, repo core.Repository) error {
8686
jsonFile := repo.RepoDir + "/bundle-list.json"
8787

8888
// TODO: Formalize lockfile concept.
89-
f, err := os.OpenFile(listFile+".lock", os.O_WRONLY|os.O_CREATE, 0600)
89+
f, err := os.OpenFile(listFile+".lock", os.O_WRONLY|os.O_CREATE, 0o600)
9090
if err != nil {
9191
return fmt.Errorf("failure to open file: %w", err)
9292
}
@@ -109,7 +109,7 @@ func WriteBundleList(list BundleList, repo core.Repository) error {
109109
return fmt.Errorf("failed to close lock file: %w", err)
110110
}
111111

112-
f, err = os.OpenFile(jsonFile+".lock", os.O_WRONLY|os.O_CREATE, 0600)
112+
f, err = os.OpenFile(jsonFile+".lock", os.O_WRONLY|os.O_CREATE, 0o600)
113113
if err != nil {
114114
return fmt.Errorf("failed to open JSON file: %w", err)
115115
}
@@ -182,8 +182,8 @@ func GetBundleHeader(bundle Bundle) (*BundleHeader, error) {
182182

183183
if line[0] == '#' &&
184184
strings.HasPrefix(line, "# v") &&
185-
strings.HasSuffix(line, " git bundle\n") {
186-
header.Version, err = strconv.ParseInt(line[3:len(line)-len(" git bundle\n")], 10, 64)
185+
strings.HasSuffix(line, " git bundle") {
186+
header.Version, err = strconv.ParseInt(line[3:len(line)-len(" git bundle")], 10, 64)
187187
if err != nil {
188188
return nil, fmt.Errorf("failed to parse bundle version: %s", err)
189189
}

0 commit comments

Comments
 (0)