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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 22 additions & 17 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)