Skip to content

Commit 8afe7d6

Browse files
Bump CACHE_VERSION (#1307)
* Support "changes" branches with gerrit Change: changes-gerrit * Bump CACHE_VERSION to 18 Change: bump
1 parent 4997cf4 commit 8afe7d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+396
-158
lines changed

josh-core/src/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::*;
22
use std::collections::HashMap;
33

4-
const CACHE_VERSION: u64 = 17;
4+
const CACHE_VERSION: u64 = 18;
55

66
lazy_static! {
77
static ref DB: std::sync::Mutex<Option<sled::Db>> = std::sync::Mutex::new(None);

josh-core/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ pub mod shell;
4949
pub struct Change {
5050
pub author: String,
5151
pub id: Option<String>,
52-
pub label: Option<String>,
5352
pub commit: git2::Oid,
5453
}
5554

5655
impl Change {
5756
fn new(commit: git2::Oid) -> Self {
5857
Self {
5958
author: Default::default(),
60-
label: Default::default(),
6159
id: Default::default(),
6260
commit,
6361
}
@@ -219,11 +217,13 @@ pub fn get_change_id(commit: &git2::Commit, sha: git2::Oid) -> Change {
219217
change.author = commit.author().email().unwrap_or("").to_string();
220218

221219
for line in commit.message().unwrap_or("").split('\n') {
220+
if line.starts_with("Change: ") {
221+
change.id = Some(line.replacen("Change: ", "", 1));
222+
// If there is a "Change-Id" as well, it will take precedence
223+
}
222224
if line.starts_with("Change-Id: ") {
223225
change.id = Some(line.replacen("Change-Id: ", "", 1));
224-
}
225-
if line.starts_with("Change: ") {
226-
change.label = Some(line.replacen("Change: ", "", 1));
226+
break;
227227
}
228228
}
229229
change

josh-proxy/src/lib.rs

+22-17
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,19 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
206206
None
207207
};
208208

209-
let mut changes = if push_mode == PushMode::Stack || push_mode == PushMode::Split {
210-
Some(vec![])
209+
let author = if let Some(p) = push_options.get("author") {
210+
p.to_string()
211211
} else {
212-
None
212+
"".to_string()
213213
};
214214

215+
let mut changes =
216+
if push_mode == PushMode::Stack || push_mode == PushMode::Split || author != "" {
217+
Some(vec![])
218+
} else {
219+
None
220+
};
221+
215222
let filterobj = josh::filter::parse(&repo_update.filter_spec)?;
216223
let new_oid = git2::Oid::from_str(new)?;
217224
let backward_new_oid = {
@@ -265,12 +272,6 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
265272
push_to
266273
};
267274

268-
let author = if let Some(p) = push_options.get("author") {
269-
p.to_string()
270-
} else {
271-
"".to_string()
272-
};
273-
274275
let to_push = if let Some(changes) = changes {
275276
let mut v = vec![];
276277
v.append(&mut changes_to_refs(&baseref, &author, changes)?);
@@ -279,6 +280,10 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
279280
split_changes(transaction.repo(), &mut v, old)?;
280281
}
281282

283+
if push_mode == PushMode::Review {
284+
v.push((ref_with_options, oid_to_push, "JOSH_PUSH".to_string()));
285+
}
286+
282287
v.push((
283288
format!(
284289
"refs/heads/@heads/{}/{}",
@@ -820,20 +825,20 @@ fn changes_to_refs(
820825
};
821826

822827
for change in changes.iter() {
823-
if let Some(label) = &change.label {
824-
if label.contains('@') {
825-
return Err(josh::josh_error("Change label must not contain '@'"));
828+
if let Some(id) = &change.id {
829+
if id.contains('@') {
830+
return Err(josh::josh_error("Change id must not contain '@'"));
826831
}
827-
if seen.contains(&label) {
832+
if seen.contains(&id) {
828833
return Err(josh::josh_error(&format!(
829834
"rejecting to push {:?} with duplicate label",
830835
change.commit
831836
)));
832837
}
833-
seen.push(label);
838+
seen.push(id);
834839
} else {
835840
return Err(josh::josh_error(&format!(
836-
"rejecting to push {:?} without label",
841+
"rejecting to push {:?} without id",
837842
change.commit
838843
)));
839844
}
@@ -847,11 +852,11 @@ fn changes_to_refs(
847852
"refs/heads/@changes/{}/{}/{}",
848853
baseref.replacen("refs/heads/", "", 1),
849854
change.author,
850-
change.label.as_ref().unwrap_or(&"".to_string()),
855+
change.id.as_ref().unwrap_or(&"".to_string()),
851856
),
852857
change.commit,
853858
change
854-
.label
859+
.id
855860
.as_ref()
856861
.unwrap_or(&"JOSH_PUSH".to_string())
857862
.to_string(),

tests/proxy/amend_patchset.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
]
125125
.
126126
|-- josh
127-
| `-- 17
127+
| `-- 18
128128
| `-- sled
129129
| |-- blobs
130130
| |-- conf

tests/proxy/authentication.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"real_repo.git" = ["::sub1/"]
125125
.
126126
|-- josh
127-
| `-- 17
127+
| `-- 18
128128
| `-- sled
129129
| |-- blobs
130130
| |-- conf

tests/proxy/caching.t

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
]
5252
.
5353
|-- josh
54-
| `-- 17
54+
| `-- 18
5555
| `-- sled
5656
| |-- blobs
5757
| |-- conf
@@ -162,7 +162,7 @@
162162
]
163163
.
164164
|-- josh
165-
| `-- 17
165+
| `-- 18
166166
| `-- sled
167167
| |-- blobs
168168
| |-- conf

tests/proxy/clone_absent_head.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
$ bash ${TESTDIR}/destroy_test_env.sh
8686
.
8787
|-- josh
88-
| `-- 17
88+
| `-- 18
8989
| `-- sled
9090
| |-- blobs
9191
| |-- conf

tests/proxy/clone_all.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"real_repo.git" = ["::sub1/"]
5454
.
5555
|-- josh
56-
| `-- 17
56+
| `-- 18
5757
| `-- sled
5858
| |-- blobs
5959
| |-- conf

tests/proxy/clone_blocked.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$ bash ${TESTDIR}/destroy_test_env.sh
1010
.
1111
|-- josh
12-
| `-- 17
12+
| `-- 18
1313
| `-- sled
1414
| |-- blobs
1515
| |-- conf

tests/proxy/clone_invalid_url.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
$ bash ${TESTDIR}/destroy_test_env.sh
3333
.
3434
|-- josh
35-
| `-- 17
35+
| `-- 18
3636
| `-- sled
3737
| |-- blobs
3838
| |-- conf

tests/proxy/clone_locked_refs.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
]
112112
.
113113
|-- josh
114-
| `-- 17
114+
| `-- 18
115115
| `-- sled
116116
| |-- blobs
117117
| |-- conf

tests/proxy/clone_prefix.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
]
7575
.
7676
|-- josh
77-
| `-- 17
77+
| `-- 18
7878
| `-- sled
7979
| |-- blobs
8080
| |-- conf

tests/proxy/clone_sha.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Check (2) and (3) but with a branch ref
9393
"real_repo.git" = ["::sub1/"]
9494
.
9595
|-- josh
96-
| `-- 17
96+
| `-- 18
9797
| `-- sled
9898
| |-- blobs
9999
| |-- conf

tests/proxy/clone_subsubtree.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
]
8888
.
8989
|-- josh
90-
| `-- 17
90+
| `-- 18
9191
| `-- sled
9292
| |-- blobs
9393
| |-- conf

tests/proxy/clone_subtree.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
]
8686
.
8787
|-- josh
88-
| `-- 17
88+
| `-- 18
8989
| `-- sled
9090
| |-- blobs
9191
| |-- conf

tests/proxy/clone_subtree_no_master.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"real_repo.git" = [":/sub1"]
7979
.
8080
|-- josh
81-
| `-- 17
81+
| `-- 18
8282
| `-- sled
8383
| |-- blobs
8484
| |-- conf

tests/proxy/clone_subtree_tags.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
]
116116
.
117117
|-- josh
118-
| `-- 17
118+
| `-- 18
119119
| `-- sled
120120
| |-- blobs
121121
| |-- conf

tests/proxy/clone_with_meta.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
]
130130
.
131131
|-- josh
132-
| `-- 17
132+
| `-- 18
133133
| `-- sled
134134
| |-- blobs
135135
| |-- conf

tests/proxy/empty_commit.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ should still be included.
8383
"real_repo.git" = ["::sub1/"]
8484
.
8585
|-- josh
86-
| `-- 17
86+
| `-- 18
8787
| `-- sled
8888
| |-- blobs
8989
| |-- conf

tests/proxy/get_version.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$ bash ${TESTDIR}/destroy_test_env.sh
88
.
99
|-- josh
10-
| `-- 17
10+
| `-- 18
1111
| `-- sled
1212
| |-- blobs
1313
| |-- conf

tests/proxy/import_export.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Flushed credential cache
301301
"repo2.git" = [":prefix=repo2"]
302302
.
303303
|-- josh
304-
| `-- 17
304+
| `-- 18
305305
| `-- sled
306306
| |-- blobs
307307
| |-- conf

tests/proxy/join_with_merge.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"real_repo.git" = [":prefix=sub1"]
6060
.
6161
|-- josh
62-
| `-- 17
62+
| `-- 18
6363
| `-- sled
6464
| |-- blobs
6565
| |-- conf

tests/proxy/markers.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
]
341341
.
342342
|-- josh
343-
| `-- 17
343+
| `-- 18
344344
| `-- sled
345345
| |-- blobs
346346
| |-- conf

tests/proxy/no_proxy.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
$ bash ${TESTDIR}/destroy_test_env.sh
3636
.
3737
|-- josh
38-
| `-- 17
38+
| `-- 18
3939
| `-- sled
4040
| |-- blobs
4141
| |-- conf

tests/proxy/no_proxy_lfs.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
$ bash ${TESTDIR}/destroy_test_env.sh
5151
.
5252
|-- josh
53-
| `-- 17
53+
| `-- 18
5454
| `-- sled
5555
| |-- blobs
5656
| |-- conf

tests/proxy/push_graphql.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"real_repo.git" = ["::sub1/"]
7070
.
7171
|-- josh
72-
| `-- 17
72+
| `-- 18
7373
| `-- sled
7474
| |-- blobs
7575
| |-- conf

tests/proxy/push_new_branch.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Check the branch again
9797
]
9898
.
9999
|-- josh
100-
| `-- 17
100+
| `-- 18
101101
| `-- sled
102102
| |-- blobs
103103
| |-- conf

tests/proxy/push_prefix.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
]
5757
.
5858
|-- josh
59-
| `-- 17
59+
| `-- 18
6060
| `-- sled
6161
| |-- blobs
6262
| |-- conf

tests/proxy/push_review.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Make sure all temporary namespace got removed
8787
]
8888
.
8989
|-- josh
90-
| `-- 17
90+
| `-- 18
9191
| `-- sled
9292
| |-- blobs
9393
| |-- conf

tests/proxy/push_review_already_in.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test for that.
4848
"real_repo.git" = []
4949
.
5050
|-- josh
51-
| `-- 17
51+
| `-- 18
5252
| `-- sled
5353
| |-- blobs
5454
| |-- conf

tests/proxy/push_review_nop_behind.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ This is a regression test for that problem.
5555
"real_repo.git" = []
5656
.
5757
|-- josh
58-
| `-- 17
58+
| `-- 18
5959
| `-- sled
6060
| |-- blobs
6161
| |-- conf

tests/proxy/push_review_old.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Flushed credential cache
8585
]
8686
.
8787
|-- josh
88-
| `-- 17
88+
| `-- 18
8989
| `-- sled
9090
| |-- blobs
9191
| |-- conf

0 commit comments

Comments
 (0)