Skip to content

Commit 351238b

Browse files
committed
Fix status verbose checksums, list file count, and restore --force
- status --verbose: keep new checksums after compare (not empty map lookups) - list: use len(manifest.Files) instead of snapshot filename length - restore --force: remove existing path before creating symlinks - Add regression tests; move design doc to docs/PROJECT_DESIGN.md; drop SYSTEMPROMPT.md
1 parent fe3fbfa commit 351238b

11 files changed

Lines changed: 321 additions & 262 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
Download the latest release from [GitHub Releases](https://github.com/Cod-e-Codes/ignoregrets/releases/latest):
2626

27-
- Linux (amd64): `ignoregrets_0.1.3_linux_amd64.tar.gz`
28-
- Linux (arm64): `ignoregrets_0.1.3_linux_arm64.tar.gz`
29-
- macOS (amd64): `ignoregrets_0.1.3_darwin_amd64.tar.gz`
30-
- macOS (arm64): `ignoregrets_0.1.3_darwin_arm64.tar.gz`
31-
- Windows (amd64): `ignoregrets_0.1.3_windows_amd64.zip`
32-
- Windows (arm64): `ignoregrets_0.1.3_windows_arm64.zip`
27+
- Linux (amd64): `ignoregrets_0.1.4_linux_amd64.tar.gz`
28+
- Linux (arm64): `ignoregrets_0.1.4_linux_arm64.tar.gz`
29+
- macOS (amd64): `ignoregrets_0.1.4_darwin_amd64.tar.gz`
30+
- macOS (arm64): `ignoregrets_0.1.4_darwin_arm64.tar.gz`
31+
- Windows (amd64): `ignoregrets_0.1.4_windows_amd64.zip`
32+
- Windows (arm64): `ignoregrets_0.1.4_windows_arm64.zip`
3333

3434
SHA256 checksums are provided in `checksums.txt` on the release page.
3535

RELEASE_NOTES.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
# ignoregrets v0.1.4
2+
3+
Bug fix release for status, list, and restore behavior.
4+
5+
## Changes
6+
7+
- Fix `status --verbose` printing empty new checksums after comparison removed entries from the working map
8+
- Fix `list` showing snapshot filename length instead of manifest file count
9+
- Fix `restore --force` failing when replacing an existing symlink at the target path
10+
- Add regression tests for all three fixes
11+
- Move project design doc to `docs/PROJECT_DESIGN.md` and remove obsolete `SYSTEMPROMPT.md`
12+
13+
## Installation
14+
15+
### Windows
16+
1. Download `ignoregrets_v0.1.4_windows_amd64.exe`
17+
2. Rename to `ignoregrets.exe`
18+
3. Move to a directory in your PATH
19+
20+
### Linux
21+
1. Download `ignoregrets_v0.1.4_linux_amd64`
22+
2. Make executable: `chmod +x ignoregrets_v0.1.4_linux_amd64`
23+
3. Move to `/usr/local/bin/ignoregrets`
24+
25+
### macOS
26+
1. Download `ignoregrets_v0.1.4_darwin_amd64`
27+
2. Make executable: `chmod +x ignoregrets_v0.1.4_darwin_amd64`
28+
3. Move to `/usr/local/bin/ignoregrets`
29+
30+
For more information, see the [README](README.md).
31+
32+
---
33+
134
# ignoregrets v0.1.2
235

336
Patch release with code quality improvements.

SYSTEMPROMPT.md

Lines changed: 0 additions & 217 deletions
This file was deleted.

cmd/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Snapshots are sorted by commit hash and timestamp.`,
2828
}
2929

3030
type snapshotInfo struct {
31-
path string
3231
commit string
3332
timestamp time.Time
3433
index int
34+
fileCount int
3535
}
3636

3737
var snapshots []snapshotInfo
@@ -53,10 +53,10 @@ Snapshots are sorted by commit hash and timestamp.`,
5353
}
5454

5555
snapshots = append(snapshots, snapshotInfo{
56-
path: file.Name(),
5756
commit: manifest.CommitHash,
5857
timestamp: manifest.Timestamp,
5958
index: manifest.Index,
59+
fileCount: len(manifest.Files),
6060
})
6161
}
6262
}
@@ -89,7 +89,7 @@ Snapshots are sorted by commit hash and timestamp.`,
8989
fmt.Printf(" [%d] %s (%d files)\n",
9090
s.index,
9191
s.timestamp.Format("2006-01-02 15:04:05"),
92-
len(s.path))
92+
s.fileCount)
9393
}
9494

9595
return nil

cmd/list_test.go

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package cmd
2+
3+
import (
4+
"archive/tar"
5+
"compress/gzip"
6+
"encoding/json"
7+
"os"
8+
"path/filepath"
9+
"testing"
10+
"time"
11+
12+
"github.com/Cod-e-Codes/ignoregrets/internal/snapshot"
13+
)
14+
15+
func TestListUsesManifestFileCount(t *testing.T) {
16+
dir := t.TempDir()
17+
snapshotsDir := filepath.Join(dir, ".ignoregrets", "snapshots")
18+
if err := os.MkdirAll(snapshotsDir, 0755); err != nil {
19+
t.Fatal(err)
20+
}
21+
22+
manifest := &snapshot.Manifest{
23+
CommitHash: "abc123",
24+
Timestamp: time.Date(2024, 1, 2, 15, 4, 0, 0, time.UTC),
25+
Index: 0,
26+
Files: map[string]string{
27+
"a.txt": "111",
28+
"b.txt": "222",
29+
"c.txt": "333",
30+
},
31+
}
32+
33+
// Filename length is unrelated to archived file count.
34+
longName := "abc123_20240102T1504_0.tar.gz"
35+
snapshotPath := filepath.Join(snapshotsDir, longName)
36+
if err := writeTestSnapshot(snapshotPath, manifest); err != nil {
37+
t.Fatal(err)
38+
}
39+
40+
f, err := os.Open(snapshotPath)
41+
if err != nil {
42+
t.Fatal(err)
43+
}
44+
readManifest, err := snapshot.ReadManifest(f)
45+
f.Close()
46+
if err != nil {
47+
t.Fatal(err)
48+
}
49+
50+
fileCount := len(readManifest.Files)
51+
if fileCount != 3 {
52+
t.Fatalf("fileCount = %d, want 3 from manifest", fileCount)
53+
}
54+
if fileCount == len(longName) {
55+
t.Fatal("file count must not equal snapshot filename length")
56+
}
57+
}
58+
59+
func writeTestSnapshot(path string, manifest *snapshot.Manifest) error {
60+
file, err := os.Create(path)
61+
if err != nil {
62+
return err
63+
}
64+
defer file.Close()
65+
66+
gw := gzip.NewWriter(file)
67+
defer gw.Close()
68+
69+
tw := tar.NewWriter(gw)
70+
defer tw.Close()
71+
72+
manifestData, err := json.Marshal(manifest)
73+
if err != nil {
74+
return err
75+
}
76+
77+
hdr := &tar.Header{
78+
Name: "manifest.json",
79+
Mode: 0644,
80+
Size: int64(len(manifestData)),
81+
}
82+
if err := tw.WriteHeader(hdr); err != nil {
83+
return err
84+
}
85+
if _, err := tw.Write(manifestData); err != nil {
86+
return err
87+
}
88+
89+
return nil
90+
}

0 commit comments

Comments
 (0)