Skip to content

Commit daf9b4c

Browse files
Introduce :committer filter (#1352)
Previously `:author` would rewrite both the author and commiter fields. Now there are seperate filters for that. Change: committer-filter
1 parent 4ef5d2c commit daf9b4c

Some content is hidden

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

56 files changed

+137
-79
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 = 21;
4+
const CACHE_VERSION: u64 = 22;
55

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

josh-core/src/filter/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ enum Op {
137137
// converting to Filter
138138
Squash(Option<std::collections::BTreeMap<LazyRef, Filter>>),
139139
Author(String, String),
140+
Committer(String, String),
140141

141142
// We use BTreeMap rather than HashMap to guarantee deterministic results when
142143
// converting to Filter
@@ -492,6 +493,13 @@ fn spec2(op: &Op) -> String {
492493
Op::Author(author, email) => {
493494
format!(":author={};{}", parse::quote(author), parse::quote(email))
494495
}
496+
Op::Committer(author, email) => {
497+
format!(
498+
":committer={};{}",
499+
parse::quote(author),
500+
parse::quote(email)
501+
)
502+
}
495503
Op::Message(m) => {
496504
format!(":{}", parse::quote(m))
497505
}
@@ -926,6 +934,12 @@ fn apply_to_commit2(
926934
Op::Author(author, email) => RewriteData {
927935
tree: commit.tree()?,
928936
author: Some((author.clone(), email.clone())),
937+
committer: None,
938+
message: None,
939+
},
940+
Op::Committer(author, email) => RewriteData {
941+
tree: commit.tree()?,
942+
author: None,
929943
committer: Some((author.clone(), email.clone())),
930944
message: None,
931945
},
@@ -989,6 +1003,7 @@ fn apply2<'a>(
9891003
Op::Squash(None) => Ok(tree),
9901004
Op::Message(_) => Ok(tree),
9911005
Op::Author(_, _) => Ok(tree),
1006+
Op::Committer(_, _) => Ok(tree),
9921007
Op::Squash(Some(_)) => Err(josh_error("not applicable to tree")),
9931008
Op::Linear => Ok(tree),
9941009
Op::Unsign => Ok(tree),

josh-core/src/filter/parse.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ fn make_op(args: &[&str]) -> JoshResult<Op> {
88
["empty"] => Ok(Op::Empty),
99
["prefix", arg] => Ok(Op::Prefix(Path::new(arg).to_owned())),
1010
["author", author, email] => Ok(Op::Author(author.to_string(), email.to_string())),
11+
["committer", author, email] => Ok(Op::Committer(author.to_string(), email.to_string())),
1112
["workspace", arg] => Ok(Op::Workspace(Path::new(arg).to_owned())),
1213
["prefix"] => Err(josh_error(indoc!(
1314
r#"

tests/filter/squash.t

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This one tag is an annotated tag, to make sure those are handled as well
4747
)
4848
4949
$ git log --graph --decorate --pretty=oneline refs/heads/filtered
50-
* d8aa5a9937f4f0bd645dbc0b591bae5cd6b6d91b (tag: filtered/tag_a, filtered) refs/tags/tag_a
50+
* 977cc3ee14c0d6163ba63bd96f4aeedd43916ba7 (tag: filtered/tag_a, filtered) refs/tags/tag_a
5151
$ git tag tag_b 0b4cf6c
5252
5353
@@ -70,55 +70,87 @@ This one tag is an annotated tag, to make sure those are handled as well
7070
[3] :squash(
7171
0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb:"refs/tags/tag_b"
7272
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
73-
d8aa5a9937f4f0bd645dbc0b591bae5cd6b6d91b:"refs/tags/filtered/tag_a"
73+
977cc3ee14c0d6163ba63bd96f4aeedd43916ba7:"refs/tags/filtered/tag_a"
7474
)
7575
[4] :author="New Author";"new@e.mail"
7676
7777
$ git log --graph --decorate --pretty=oneline refs/heads/filtered
78-
* 5b1a753860ca124024f6dfb4fd018fe7df8beae4 (tag: filtered/tag_a, filtered) refs/tags/tag_a
78+
* be41caf35896090033cfd103e06aae721a3ce541 (tag: filtered/tag_a, filtered) refs/tags/tag_a
7979
|\
80-
* 96a731a4d64a8928e6af7abb2d425df3812b4197 (tag: filtered/tag_b) refs/tags/tag_b
80+
* 64f712c4615dbf5e9e0a1c4cdf65b2da2138f4be (tag: filtered/tag_b) refs/tags/tag_b
8181
82-
$ git log --graph --pretty=%an:%ae refs/heads/master
83-
* Josh:josh@example.com
82+
$ git log --graph --pretty=%an:%ae-%cn:%ce refs/heads/master
83+
* Josh:josh@example.com-Josh:josh@example.com
8484
|\
85-
| * Josh:josh@example.com
86-
| * Josh:josh@example.com
87-
* | Josh:josh@example.com
85+
| * Josh:josh@example.com-Josh:josh@example.com
86+
| * Josh:josh@example.com-Josh:josh@example.com
87+
* | Josh:josh@example.com-Josh:josh@example.com
8888
|/
89-
* Josh:josh@example.com
90-
$ git log --graph --pretty=%an:%ae refs/heads/filtered
91-
* New Author:new@e.mail
89+
* Josh:josh@example.com-Josh:josh@example.com
90+
$ git log --graph --pretty=%an:%ae-%cn:%ce refs/heads/filtered
91+
* New Author:new@e.mail-Josh:josh@example.com
9292
|\
93-
* New Author:new@e.mail
93+
* New Author:new@e.mail-Josh:josh@example.com
94+
95+
$ josh-filter -s --squash-pattern "refs/tags/*" :committer=\"New\ Author\"\;\"new@e.mail\" --update refs/heads/filtered
96+
[1] :"refs/tags/filtered/filtered/tag_a"
97+
[1] :"refs/tags/filtered/tag_a"
98+
[1] :"refs/tags/filtered/tag_b"
99+
[1] :"refs/tags/tag_a"
100+
[1] :"refs/tags/tag_b"
101+
[1] :squash(
102+
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
103+
)
104+
[3] :squash(
105+
0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb:"refs/tags/tag_b"
106+
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
107+
977cc3ee14c0d6163ba63bd96f4aeedd43916ba7:"refs/tags/filtered/tag_a"
108+
)
109+
[4] :author="New Author";"new@e.mail"
110+
[5] :committer="New Author";"new@e.mail"
111+
[5] :squash(
112+
0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb:"refs/tags/tag_b"
113+
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
114+
64f712c4615dbf5e9e0a1c4cdf65b2da2138f4be:"refs/tags/filtered/tag_b"
115+
a68763bdf2f45a44304067954855749e366a5533:"refs/tags/filtered/filtered/tag_a"
116+
be41caf35896090033cfd103e06aae721a3ce541:"refs/tags/filtered/tag_a"
117+
)
118+
$ git log --graph --pretty=%an:%ae-%cn:%ce refs/heads/filtered
119+
* Josh:josh@example.com-New Author:new@e.mail
120+
|\
121+
* Josh:josh@example.com-New Author:new@e.mail
94122
95123
$ git tag tag_c 975d4c4
96124
97125
$ git show-ref | grep refs/heads > squashlist
98126
$ cat squashlist
99127
86871b8775ad3baca86484337d1072aa1d386f7e refs/heads/branch2
100-
5b1a753860ca124024f6dfb4fd018fe7df8beae4 refs/heads/filtered
128+
97c6007771c497c9530d61aa89af663daebb1625 refs/heads/filtered
101129
1d69b7d2651f744be3416f2ad526aeccefb99310 refs/heads/master
102130
$ josh-filter -s --squash-file squashlist :author=\"John\ Doe\"\;\"new@e.mail\" --update refs/heads/filtered -p > filter.josh
103131
$ cat filter.josh
104132
:squash(
105133
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/heads/master"
106-
5b1a753860ca124024f6dfb4fd018fe7df8beae4:"refs/heads/filtered"
107134
86871b8775ad3baca86484337d1072aa1d386f7e:"refs/heads/branch2"
135+
97c6007771c497c9530d61aa89af663daebb1625:"refs/heads/filtered"
108136
):author="John Doe";"new@e.mail"
109137
110138
$ josh-filter -s --squash-pattern "refs/tags/*" :author=\"New\ Author\"\;\"new@e.mail\" --update refs/heads/filtered -p > filter.josh
111139
$ cat filter.josh
112140
:squash(
113141
0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb:"refs/tags/tag_b"
114142
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
115-
5b1a753860ca124024f6dfb4fd018fe7df8beae4:"refs/tags/filtered/tag_a"
116-
68dc45079334d83e5b61d2ceeda035b96da4c838:"refs/tags/filtered/filtered/tag_a"
117-
96a731a4d64a8928e6af7abb2d425df3812b4197:"refs/tags/filtered/tag_b"
143+
1dd879133bc80f7d180bd98268412f8ee61226f2:"refs/tags/filtered/tag_b"
118144
975d4c4975912729482cc864d321c5196a969271:"refs/tags/tag_c"
145+
97c6007771c497c9530d61aa89af663daebb1625:"refs/tags/filtered/tag_a"
146+
a91f2e4061d13b9adcb6d8ca63e17c8bbc5bed55:"refs/tags/filtered/filtered/tag_a"
147+
b7e3b7815c4d7c8738545526b20308b1240137c7:"refs/tags/filtered/filtered/filtered/tag_a"
148+
c4215db39f3cd96f07fe4c1f701dad39d5f5dec3:"refs/tags/filtered/filtered/tag_b"
119149
):author="New Author";"new@e.mail"
120150
$ josh-filter -s --file filter.josh --update refs/heads/filtered
151+
[1] :"refs/tags/filtered/filtered/tag_a"
121152
[1] :"refs/tags/filtered/tag_a"
153+
[1] :"refs/tags/filtered/tag_b"
122154
[1] :"refs/tags/tag_a"
123155
[1] :"refs/tags/tag_b"
124156
[1] :"refs/tags/tag_c"
@@ -128,22 +160,32 @@ This one tag is an annotated tag, to make sure those are handled as well
128160
[3] :squash(
129161
0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb:"refs/tags/tag_b"
130162
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
131-
5b1a753860ca124024f6dfb4fd018fe7df8beae4:"refs/tags/filtered/tag_a"
132-
68dc45079334d83e5b61d2ceeda035b96da4c838:"refs/tags/filtered/filtered/tag_a"
133-
96a731a4d64a8928e6af7abb2d425df3812b4197:"refs/tags/filtered/tag_b"
163+
1dd879133bc80f7d180bd98268412f8ee61226f2:"refs/tags/filtered/tag_b"
134164
975d4c4975912729482cc864d321c5196a969271:"refs/tags/tag_c"
165+
97c6007771c497c9530d61aa89af663daebb1625:"refs/tags/filtered/tag_a"
166+
a91f2e4061d13b9adcb6d8ca63e17c8bbc5bed55:"refs/tags/filtered/filtered/tag_a"
167+
b7e3b7815c4d7c8738545526b20308b1240137c7:"refs/tags/filtered/filtered/filtered/tag_a"
168+
c4215db39f3cd96f07fe4c1f701dad39d5f5dec3:"refs/tags/filtered/filtered/tag_b"
135169
)
136170
[3] :squash(
137171
0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb:"refs/tags/tag_b"
138172
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
139-
d8aa5a9937f4f0bd645dbc0b591bae5cd6b6d91b:"refs/tags/filtered/tag_a"
173+
977cc3ee14c0d6163ba63bd96f4aeedd43916ba7:"refs/tags/filtered/tag_a"
174+
)
175+
[5] :committer="New Author";"new@e.mail"
176+
[5] :squash(
177+
0b4cf6c9efbbda1eada39fa9c1d21d2525b027bb:"refs/tags/tag_b"
178+
1d69b7d2651f744be3416f2ad526aeccefb99310:"refs/tags/tag_a"
179+
64f712c4615dbf5e9e0a1c4cdf65b2da2138f4be:"refs/tags/filtered/tag_b"
180+
a68763bdf2f45a44304067954855749e366a5533:"refs/tags/filtered/filtered/tag_a"
181+
be41caf35896090033cfd103e06aae721a3ce541:"refs/tags/filtered/tag_a"
140182
)
141183
[6] :author="New Author";"new@e.mail"
142184
143185
$ git log --graph --decorate --pretty=oneline refs/heads/filtered
144-
* 9fe45cb2bead844630852ab338ecd8e073f8ba50 (filtered) refs/tags/tag_a
186+
* 2826b9a173c7a7d5c83d9ae2614de89c77205d83 (filtered) refs/tags/tag_a
145187
|\
146-
| * d6b88d4c1cc566b7f4d9b51353ec6f3204a93b81 refs/tags/tag_c
188+
| * 63f8653625759f860ee31cce2d4e207974da1c37 refs/tags/tag_c
147189
|/
148-
* 96a731a4d64a8928e6af7abb2d425df3812b4197 (tag: filtered/tag_b) refs/tags/tag_b
190+
* 64f712c4615dbf5e9e0a1c4cdf65b2da2138f4be refs/tags/tag_b
149191

tests/filter/squash_empty_initial.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@
5252
)
5353
5454
$ git log --graph --decorate --pretty=oneline refs/heads/filtered
55-
* d8aa5a9937f4f0bd645dbc0b591bae5cd6b6d91b (tag: filtered/tag_a, filtered) refs/tags/tag_a
55+
* 977cc3ee14c0d6163ba63bd96f4aeedd43916ba7 (tag: filtered/tag_a, filtered) refs/tags/tag_a

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-
| `-- 21
127+
| `-- 22
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-
| `-- 21
127+
| `-- 22
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-
| `-- 21
54+
| `-- 22
5555
| `-- sled
5656
| |-- blobs
5757
| |-- conf
@@ -162,7 +162,7 @@
162162
]
163163
.
164164
|-- josh
165-
| `-- 21
165+
| `-- 22
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-
| `-- 21
88+
| `-- 22
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-
| `-- 21
56+
| `-- 22
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-
| `-- 21
12+
| `-- 22
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-
| `-- 21
35+
| `-- 22
3636
| `-- sled
3737
| |-- blobs
3838
| |-- conf

tests/proxy/clone_locked_refs.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
]
112112
.
113113
|-- josh
114-
| `-- 21
114+
| `-- 22
115115
| `-- sled
116116
| |-- blobs
117117
| |-- conf

tests/proxy/clone_prefix.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
]
7575
.
7676
|-- josh
77-
| `-- 21
77+
| `-- 22
7878
| `-- sled
7979
| |-- blobs
8080
| |-- conf

tests/proxy/clone_sha.t

Lines changed: 1 addition & 1 deletion
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-
| `-- 21
96+
| `-- 22
9797
| `-- sled
9898
| |-- blobs
9999
| |-- conf

tests/proxy/clone_subsubtree.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
]
8888
.
8989
|-- josh
90-
| `-- 21
90+
| `-- 22
9191
| `-- sled
9292
| |-- blobs
9393
| |-- conf

tests/proxy/clone_subtree.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
]
8686
.
8787
|-- josh
88-
| `-- 21
88+
| `-- 22
8989
| `-- sled
9090
| |-- blobs
9191
| |-- conf

tests/proxy/clone_subtree_no_master.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"real_repo.git" = [":/sub1"]
7979
.
8080
|-- josh
81-
| `-- 21
81+
| `-- 22
8282
| `-- sled
8383
| |-- blobs
8484
| |-- conf

tests/proxy/clone_subtree_tags.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
]
116116
.
117117
|-- josh
118-
| `-- 21
118+
| `-- 22
119119
| `-- sled
120120
| |-- blobs
121121
| |-- conf

tests/proxy/clone_with_meta.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
]
130130
.
131131
|-- josh
132-
| `-- 21
132+
| `-- 22
133133
| `-- sled
134134
| |-- blobs
135135
| |-- conf

tests/proxy/empty_commit.t

Lines changed: 1 addition & 1 deletion
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-
| `-- 21
86+
| `-- 22
8787
| `-- sled
8888
| |-- blobs
8989
| |-- conf

tests/proxy/get_version.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
$ bash ${TESTDIR}/destroy_test_env.sh
88
.
99
|-- josh
10-
| `-- 21
10+
| `-- 22
1111
| `-- sled
1212
| |-- blobs
1313
| |-- conf

tests/proxy/import_export.t

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

tests/proxy/join_subtree.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Make sure all temporary namespace got removed
132132
]
133133
.
134134
|-- josh
135-
| `-- 21
135+
| `-- 22
136136
| `-- sled
137137
| |-- blobs
138138
| |-- conf

0 commit comments

Comments
 (0)