Skip to content

Commit 7b72a8e

Browse files
Introduce :join() filter (#1348)
The filter allows to combine branches from multiple upstream repos without a need to go though a push via Josh Change: join-filter
1 parent 2dde605 commit 7b72a8e

File tree

8 files changed

+607
-99
lines changed

8 files changed

+607
-99
lines changed

docs/src/reference/filters.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ for all further ancestors (and so on).
109109
This special value `0000000000000000000000000000000000000000` can be used as a `<sha_n>` to filter
110110
commits that don't match any of the other shas.
111111

112+
### Join multiple histories into one **:join(<sha_0>:filter_0,...,<sha_N>:filter_N)**
113+
114+
Produce the history that would be the result of pushing the passed branches with the
115+
passed filters into the upstream.
116+
112117
Filter order matters
113118
--------------------
114119

josh-core/src/filter/grammar.pest

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ GROUP_START = _{ "[" }
88
GROUP_END = _{ "]" }
99
PATH = _{ (ALNUM | "/")+ }
1010
filter_path = { PATH }
11+
argument = { string | PATH }
12+
rev = { string | ALNUM+ }
1113

12-
string = ${ "\"" ~ inner ~ "\"" }
14+
sstring = _{"\'" ~ inner ~ "\'"}
15+
dstring = _{"\"" ~ inner ~ "\""}
16+
string = ${ sstring | dstring }
1317
inner = @{ char* }
1418
char = {
15-
!("\"" | "\\") ~ ANY
16-
| "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | "u")
19+
!("\"" | "\'" | "\\") ~ ANY
20+
| "\\" ~ ("\"" | "\'" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | "u")
1721
}
1822

1923
filter_spec = { (
2024
filter_group
2125
| filter_rev
26+
| filter_join
2227
| filter_replace
2328
| filter_squash
2429
| filter_presub
@@ -38,12 +43,22 @@ filter_noarg = { CMD_START ~ cmd }
3843
filter_rev = {
3944
CMD_START ~ "rev" ~ "("
4045
~ NEWLINE*
41-
~ (argument ~ filter_spec)?
42-
~ (CMD_SEP+ ~ (argument ~ filter_spec))*
46+
~ (rev ~ filter_spec)?
47+
~ (CMD_SEP+ ~ (rev ~ filter_spec))*
4348
~ NEWLINE*
4449
~ ")"
4550
}
4651

52+
filter_join = {
53+
CMD_START ~ "join" ~ "("
54+
~ NEWLINE*
55+
~ (rev ~ filter_spec)?
56+
~ (CMD_SEP+ ~ (rev ~ filter_spec))*
57+
~ NEWLINE*
58+
~ ")"
59+
}
60+
61+
4762
filter_replace = {
4863
CMD_START ~ "replace" ~ "("
4964
~ NEWLINE*
@@ -56,14 +71,12 @@ filter_replace = {
5671
filter_squash = {
5772
CMD_START ~ "squash" ~ "("
5873
~ NEWLINE*
59-
~ (argument ~ ":" ~ string)?
60-
~ (CMD_SEP+ ~ (argument ~ ":" ~ string))*
74+
~ (rev ~ ":" ~ string)?
75+
~ (CMD_SEP+ ~ (rev ~ ":" ~ string))*
6176
~ NEWLINE*
6277
~ ")"
6378
}
6479

65-
argument = { string | PATH }
66-
6780
cmd = { ALNUM+ }
6881

6982
file_entry = { dst_path ~ "=" ~ filter_spec }

0 commit comments

Comments
 (0)