Skip to content

Commit bbd14b6

Browse files
Support cross workspace amend
Change: ws-amend
1 parent 2dde605 commit bbd14b6

Some content is hidden

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

59 files changed

+344
-69
lines changed

Diff for: Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ tempfile = "3.10.1"
3737

3838
[workspace.dependencies.git2]
3939
default-features = false
40-
version = "0.19"
40+
version = "0.18.3"
4141

4242
[workspace.dependencies.juniper]
4343
version = "0.15.11"

Diff for: docs/src/reference/cli.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ history, taking a filter specification as argument.
99

1010
It can be installed with the following Cargo command, assuming Rust is installed:
1111
```shell
12-
cargo install josh-filter --git https://github.com/josh-project/josh.git
12+
cargo install josh --git https://github.com/josh-project/josh.git
1313
```
1414

1515
git-sync

Diff for: 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 = 20;
4+
const CACHE_VERSION: u64 = 19;
55

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

Diff for: josh-core/src/history.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,22 @@ pub fn unapply_filter(
441441
let tree = module_commit.tree()?;
442442
let commit_message = module_commit.summary().unwrap_or("NO COMMIT MESSAGE");
443443

444-
let new_trees: JoshResult<Vec<_>> = {
444+
let mut nt = None;
445+
if let Some(change_ids) = change_ids {
446+
for c in change_ids.iter() {
447+
let cid = get_change_id(&module_commit, ret);
448+
449+
if c.id == cid.id {
450+
let x = transaction.repo().find_commit(c.commit)?;
451+
nt = Some(filter::unapply(transaction, filter, tree.clone(), x.tree()?)?.id());
452+
break;
453+
}
454+
}
455+
}
456+
457+
let new_trees: JoshResult<Vec<_>> = if let Some(nt) = nt {
458+
Ok(vec![nt])
459+
} else {
445460
let span = tracing::span!(
446461
tracing::Level::TRACE,
447462
"unapply filter",

Diff for: josh-core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct Change {
3838
}
3939

4040
impl Change {
41-
fn new(commit: git2::Oid) -> Self {
41+
pub fn new(commit: git2::Oid) -> Self {
4242
Self {
4343
author: Default::default(),
4444
id: Default::default(),

Diff for: josh-proxy/src/bin/josh-proxy.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1185,9 +1185,7 @@ async fn call_service(
11851185
while path.contains("//") {
11861186
path = path.replace("//", "/");
11871187
}
1188-
percent_encoding::percent_decode_str(&path)
1189-
.decode_utf8_lossy()
1190-
.to_string()
1188+
path
11911189
};
11921190

11931191
if let Some(resource_path) = path.strip_prefix("/~/ui") {

Diff for: josh-proxy/src/lib.rs

+46-6
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
259259
None
260260
};
261261

262+
if changes.is_some() && push_mode == PushMode::Review {
263+
changes = Some(refs_to_changes(
264+
&transaction_mirror,
265+
&baseref.replacen("refs/heads/", "", 1),
266+
&author,
267+
));
268+
}
269+
262270
let filter = josh::filter::parse(&repo_update.filter_spec)?;
263271
let new_oid = git2::Oid::from_str(new)?;
264272
let backward_new_oid = {
@@ -868,6 +876,38 @@ impl Drop for TmpGitNamespace {
868876
}
869877
}
870878

879+
fn refs_to_changes(
880+
transaction: &josh::cache::Transaction,
881+
baseref: &str,
882+
change_author: &str,
883+
) -> Vec<josh::Change> {
884+
let mut changes = vec![];
885+
let glob = transaction.refname(&format!(
886+
"refs/heads/@changes/{}/{}/*",
887+
baseref, change_author
888+
));
889+
890+
for r in transaction.repo().references_glob(&glob).unwrap() {
891+
let r = r.unwrap();
892+
let mut change = josh::Change::new(r.target().unwrap());
893+
change.author = change_author.to_string();
894+
895+
let id = r.name().unwrap().replacen(
896+
&transaction.refname(&format!(
897+
"refs/heads/@changes/{}/{}/",
898+
baseref, change_author
899+
)),
900+
"",
901+
1,
902+
);
903+
change.id = Some(id);
904+
905+
changes.push(change);
906+
}
907+
908+
return changes;
909+
}
910+
871911
fn changes_to_refs(
872912
baseref: &str,
873913
change_author: &str,
@@ -887,12 +927,12 @@ fn changes_to_refs(
887927
if id.contains('@') {
888928
return Err(josh::josh_error("Change id must not contain '@'"));
889929
}
890-
if seen.contains(&id) {
891-
return Err(josh::josh_error(&format!(
892-
"rejecting to push {:?} with duplicate label",
893-
change.commit
894-
)));
895-
}
930+
//if seen.contains(&id) {
931+
// return Err(josh::josh_error(&format!(
932+
// "rejecting to push {:?} with duplicate label",
933+
// change.commit
934+
// )));
935+
//}
896936
seen.push(id);
897937
} else {
898938
return Err(josh::josh_error(&format!(

Diff for: tests/proxy/amend_patchset.t

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

Diff for: 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-
| `-- 20
127+
| `-- 19
128128
| `-- sled
129129
| |-- blobs
130130
| |-- conf

Diff for: tests/proxy/caching.t

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

Diff for: 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-
| `-- 20
88+
| `-- 19
8989
| `-- sled
9090
| |-- blobs
9191
| |-- conf

Diff for: 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-
| `-- 20
56+
| `-- 19
5757
| `-- sled
5858
| |-- blobs
5959
| |-- conf

Diff for: 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-
| `-- 20
12+
| `-- 19
1313
| `-- sled
1414
| |-- blobs
1515
| |-- conf

Diff for: 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-
| `-- 20
35+
| `-- 19
3636
| `-- sled
3737
| |-- blobs
3838
| |-- conf

Diff for: 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-
| `-- 20
114+
| `-- 19
115115
| `-- sled
116116
| |-- blobs
117117
| |-- conf

Diff for: tests/proxy/clone_prefix.t

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

Diff for: 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-
| `-- 20
96+
| `-- 19
9797
| `-- sled
9898
| |-- blobs
9999
| |-- conf

Diff for: tests/proxy/clone_subsubtree.t

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

Diff for: tests/proxy/clone_subtree.t

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

Diff for: 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-
| `-- 20
81+
| `-- 19
8282
| `-- sled
8383
| |-- blobs
8484
| |-- conf

Diff for: 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-
| `-- 20
118+
| `-- 19
119119
| `-- sled
120120
| |-- blobs
121121
| |-- conf

Diff for: 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-
| `-- 20
132+
| `-- 19
133133
| `-- sled
134134
| |-- blobs
135135
| |-- conf

Diff for: 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-
| `-- 20
86+
| `-- 19
8787
| `-- sled
8888
| |-- blobs
8989
| |-- conf

Diff for: 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-
| `-- 20
10+
| `-- 19
1111
| `-- sled
1212
| |-- blobs
1313
| |-- conf

Diff for: 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-
| `-- 20
304+
| `-- 19
305305
| `-- sled
306306
| |-- blobs
307307
| |-- conf

Diff for: 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-
| `-- 20
62+
| `-- 19
6363
| `-- sled
6464
| |-- blobs
6565
| |-- conf

Diff for: tests/proxy/markers.t

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

Diff for: 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-
| `-- 20
38+
| `-- 19
3939
| `-- sled
4040
| |-- blobs
4141
| |-- conf

Diff for: 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-
| `-- 20
53+
| `-- 19
5454
| `-- sled
5555
| |-- blobs
5656
| |-- conf

0 commit comments

Comments
 (0)