Commit 566aaa8
authored
fix(internal/librarian): ignore retracted tags when report version (#3063)
Introduce a hardcoded list of retracted versions and use pseudo-version
string instead.
It's less ideal that we keep this hardcoded apart from go.mod record.
But consider retracted versions are should be fairly rare, this should
be acceptable.
**The issue:**
v1.0.0 and v1.0.1 was previously retracted and added to go.mod retract
list in #2904. These tags
are still present, this caused problem to `version` command as
`info.Main.Versio` is determined during `go build` and for local builds,
it would end up prefix with "v1.0.2-".
Note, this problem only occurs for local dev builds from untagged
commits. If you run version command from v0.7.0, it correctly prints the
version.
**Alternative approaches considered:**
- **Runtime `go.mod` parsing**: This makes the binary fragile.
the binary dependent on the presence and structure of `go.mod` at
runtime,
not the best practice.
- **`go generate` for retraction list**: Create a build-time script that
reads go.mod and automatically generates a Go source file containing the
list of retracted versions. The complexity of this setup and parsing
logic seems overkill for these rare occurrences.
- **delete retracted tags and `git fetch --prune`**: Not best practice
as it's a destructive action that rewrites history.
Fix #30481 parent 9a37edc commit 566aaa8
3 files changed
+48
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
27 | 32 | | |
28 | 33 | | |
29 | 34 | | |
| |||
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
38 | | - | |
39 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
40 | 55 | | |
| 56 | + | |
| 57 | + | |
41 | 58 | | |
| 59 | + | |
| 60 | + | |
42 | 61 | | |
43 | 62 | | |
44 | 63 | | |
| |||
52 | 71 | | |
53 | 72 | | |
54 | 73 | | |
55 | | - | |
56 | 74 | | |
57 | 75 | | |
58 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
93 | 119 | | |
94 | 120 | | |
95 | 121 | | |
| |||
0 commit comments