Skip to content

Commit ee4d371

Browse files
authored
Merge pull request #10962 from gitbutlerapp/kv-branch-63
fix(commit): always read CHANGE_ID env or generate UUID by default
2 parents 4799f25 + da8241a commit ee4d371

File tree

7 files changed

+16
-27
lines changed

7 files changed

+16
-27
lines changed

crates/but-cherry-apply/tests/fixtures/cherry_apply.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ git init remote
1313
git add . && git commit -m "init"
1414
)
1515

16-
CHANGE_ID=0
16+
GITBUTLER_CHANGE_ID=0
1717
function commit_stack() {
1818
local stack="${1:?}"
1919
local message="${2:?}"
20-
((CHANGE_ID += 1))
21-
CHANGE_ID=$CHANGE_ID $CLI branch commit "$stack" -m "$message"
20+
((GITBUTLER_CHANGE_ID += 1))
21+
GITBUTLER_CHANGE_ID=$GITBUTLER_CHANGE_ID $CLI branch commit "$stack" -m "$message"
2222
}
2323

2424
export GITBUTLER_CLI_DATA_DIR=../user/gitbutler/app-data

crates/but-core/src/commit.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ impl Default for HeadersV2 {
9696
HeadersV2 {
9797
// Change ID using base16 encoding
9898
change_id: if cfg!(feature = "testing") {
99-
// TODO: remove the CHANGE_ID dependency, but old tests still need it.
100-
// In future, the 'testing' feature alone should be enough.
101-
if std::env::var("CHANGE_ID").is_ok() {
99+
if std::env::var("GITBUTLER_CHANGE_ID").is_ok() {
102100
ChangeId::from_number_for_testing(1)
103101
} else {
104102
ChangeId::generate()

crates/but-hunk-dependency/tests/fixtures/dependencies.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ git init remote
88
git add . && git commit -m "init"
99
)
1010

11-
CHANGE_ID=0
11+
GITBUTLER_CHANGE_ID=0
1212
function commit_stack() {
1313
local stack="${1:?}"
1414
local message="${2:?}"
15-
((CHANGE_ID += 1))
16-
CHANGE_ID=$CHANGE_ID $CLI branch commit "$stack" -m "$message"
15+
((GITBUTLER_CHANGE_ID += 1))
16+
GITBUTLER_CHANGE_ID=$GITBUTLER_CHANGE_ID $CLI branch commit "$stack" -m "$message"
1717
}
1818

1919
export GITBUTLER_CLI_DATA_DIR=../user/gitbutler/app-data
@@ -499,8 +499,8 @@ add this line
499499

500500
# Update the project.
501501
git fetch origin
502-
((CHANGE_ID += 1))
503-
CHANGE_ID=$CHANGE_ID $CLI integrate-upstream merge
502+
((GITBUTLER_CHANGE_ID += 1))
503+
GITBUTLER_CHANGE_ID=$GITBUTLER_CHANGE_ID $CLI integrate-upstream merge
504504

505505
echo "1
506506
2

crates/but-testsupport/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub fn assure_stable_env() {
115115
.set("GIT_COMMITTER_DATE", "2000-01-02 00:00:00 +0000")
116116
.set("GIT_COMMITTER_EMAIL", "[email protected]")
117117
.set("GIT_COMMITTER_NAME", "committer (From Env)")
118-
.set("CHANGE_ID", "change-id");
118+
.set("GITBUTLER_CHANGE_ID", "change-id");
119119
// assure it doesn't get racy.
120120
std::mem::forget(env);
121121
}

crates/but-worktrees/tests/fixtures/worktree.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function tick () {
2929
git clone remote stacked-and-parallel
3030
(cd stacked-and-parallel
3131
tick
32-
export CHANGE_ID=851ad981-c986-4bb4-8be9-deadbeefeba2
32+
export GITBUTLER_CHANGE_ID=851ad981-c986-4bb4-8be9-deadbeefeba2
3333

3434
git config user.name "Author"
3535
git config user.email "[email protected]"
@@ -63,7 +63,7 @@ git clone remote stacked-and-parallel
6363
git clone remote stacked-branches
6464
(cd stacked-branches
6565
tick
66-
export CHANGE_ID=851ad981-c986-4bb4-8be9-deadbeefeba2
66+
export GITBUTLER_CHANGE_ID=851ad981-c986-4bb4-8be9-deadbeefeba2
6767

6868
git config user.name "Author"
6969
git config user.email "[email protected]"
@@ -84,4 +84,4 @@ git clone remote stacked-branches
8484
$CLI commit -m "feature-b: add line 1" feature-b
8585
echo "feature-b line 2" > bar.txt
8686
$CLI commit -m "feature-b: add line 2" feature-b
87-
)
87+
)

crates/but/tests/but/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl Sandbox {
182182
cmd = cmd
183183
.args(shell_words::split(args).expect("statically known args must split correctly"))
184184
}
185-
self.with_updated_env(cmd).env("CHANGE_ID", "42")
185+
self.with_updated_env(cmd).env("GITBUTLER_CHANGE_ID", "42")
186186
}
187187

188188
/// Invoke an isolated `git` with the given `args`, which will be split automatically.

crates/gitbutler-commit/src/commit_headers.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,8 @@ impl Default for CommitHeadersV2 {
3636
fn default() -> Self {
3737
CommitHeadersV2 {
3838
// Change ID using base16 encoding
39-
change_id: if cfg!(feature = "testing") {
40-
std::env::var("CHANGE_ID").unwrap_or_else(|_| {
41-
eprintln!(
42-
"With 'testing' feature the `CHANGE_ID` \
43-
environment variable can be set have stable values"
44-
);
45-
Uuid::new_v4().to_string()
46-
})
47-
} else {
48-
Uuid::new_v4().to_string()
49-
},
39+
change_id: std::env::var("GITBUTLER_CHANGE_ID")
40+
.unwrap_or_else(|_| Uuid::new_v4().to_string()),
5041
conflicted: None,
5142
}
5243
}

0 commit comments

Comments
 (0)