Commit ba289f3
authored
Use full Git hash in generated version files (#12001)
fix: Use full Git hash in generated version files
Git chooses the minimum unique abbreviation when `--short` is used.
That abbreviation can have a different length when runners have
different Git objects, even when both jobs build the same commit. This
produces different version files and prevents reproducible JARs across
jobs.
Emit the full commit hash in the version file instead, for example:
1.65.0-SNAPSHOT~846103dfeb02cb7e162b0404af6d87a4882e2e91
Also, capture the project name during configuration so the task action
does not access the Gradle project.
https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortltlengthgt
---
The validate build scan reported for `:dd-trace-api:writeVersionNumberFile`:
```
The task was not up-to-date because of the following reasons:
Value of input property 'gitHash' has changed for task ':dd-trace-api:writeVersionNumberFile'
```
chore: Keep a 10 char hex abbreviation
The tracer version string is propagated today by a few components:
* tracer
* telemetry
* remote config poller
* crash-tracking
In all cases the tracer version is processed as an "opaque" string and
ends up as a tag value for the tracer.
The hash in the version string packaged in the agent jar shows the
abbreviation has been growing over the years 7, 8, 9, 10, (and probaly
soon 11) chars over the repo's history.
Given the hash surfaces in UI, let's truncate it to 10 chars.
https://git-scm.com/docs/hash-function-transition.html
Co-authored-by: brice.dutheil <brice.dutheil@datadoghq.com>1 parent 01b5e2c commit ba289f3
2 files changed
Lines changed: 16 additions & 4 deletions
File tree
- buildSrc/src
- main/kotlin/datadog/gradle/plugin/version
- test/kotlin/datadog/gradle/plugin/version
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
30 | | - | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
36 | 47 | | |
37 | 48 | | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
41 | 52 | | |
42 | | - | |
| 53 | + | |
43 | 54 | | |
44 | | - | |
| 55 | + | |
45 | 56 | | |
46 | 57 | | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
0 commit comments