Commit e2a7abb
Add self-updater for CLI binary (#274)
* Add self-updater for CLI binary
- Two-phase update: check manifest, apply on next run
- Verify archive checksum before replacing binary
- Skip in CI and dev builds, add config opt-out
- Bump version to 2.0.45
* Fix archive download URL to include /build/ path segment
The CDN serves archives under /build/, but the URL was constructed
without it, causing 404 errors during self-update downloads.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix DeepSource review issues in self-updater
- Handle os.UserHomeDir() error to prevent state file in relative paths
- Restrict config dir permissions from 0o755 to 0o750
- Limit download size with io.LimitReader (50MB cap)
- Replace unused parameter `r` with `_` in test handler
- Refactor replaceBinary into testable replaceBinaryAt function
- Rewrite tests to call actual functions instead of reimplementing logic
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix remaining DeepSource issues: test logic and coverage gaps
- Rewrite TestCheckForUpdate_AlreadyUpToDate to call CheckForUpdate
with a mock HTTP server instead of reimplementing logic
- Add tests for FetchManifest, downloadFile, and error paths
(HTTP errors, network errors, checksum mismatch, missing platform,
nil build info, zip archive path)
- Add parseSemver test cases for invalid minor/patch and pre-release
- Add ClearBuildInfo helper for test setup
- Update package coverage from 47.5% to ~80%
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Signed-off-by: Sourya Vatsyayan <sourya@deepsource.io>
Co-authored-by: Sourya Vatsyayan <sourya@deepsource.io>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 51594ab commit e2a7abb
File tree
9 files changed
+1206
-5
lines changed- buildinfo
- cmd/deepsource
- config
- internal/update
9 files changed
+1206
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| 15 | + | |
14 | 16 | | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| |||
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
70 | 100 | | |
71 | 101 | | |
72 | 102 | | |
| |||
78 | 108 | | |
79 | 109 | | |
80 | 110 | | |
81 | | - | |
| 111 | + | |
82 | 112 | | |
83 | | - | |
| 113 | + | |
| 114 | + | |
84 | 115 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 53 | + | |
0 commit comments