Skip to content

Commit

Permalink
Introduce :join() filter (#1348)
Browse files Browse the repository at this point in the history
The filter allows to combine branches from multiple upstream
repos without a need to go though a push via Josh

Change: join-filter
  • Loading branch information
christian-schilling authored Aug 6, 2024
1 parent 2dde605 commit 7b72a8e
Show file tree
Hide file tree
Showing 8 changed files with 607 additions and 99 deletions.
5 changes: 5 additions & 0 deletions docs/src/reference/filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ for all further ancestors (and so on).
This special value `0000000000000000000000000000000000000000` can be used as a `<sha_n>` to filter
commits that don't match any of the other shas.

### Join multiple histories into one **:join(<sha_0>:filter_0,...,<sha_N>:filter_N)**

Produce the history that would be the result of pushing the passed branches with the
passed filters into the upstream.

Filter order matters
--------------------

Expand Down
31 changes: 22 additions & 9 deletions josh-core/src/filter/grammar.pest
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ GROUP_START = _{ "[" }
GROUP_END = _{ "]" }
PATH = _{ (ALNUM | "/")+ }
filter_path = { PATH }
argument = { string | PATH }
rev = { string | ALNUM+ }

string = ${ "\"" ~ inner ~ "\"" }
sstring = _{"\'" ~ inner ~ "\'"}
dstring = _{"\"" ~ inner ~ "\""}
string = ${ sstring | dstring }
inner = @{ char* }
char = {
!("\"" | "\\") ~ ANY
| "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | "u")
!("\"" | "\'" | "\\") ~ ANY
| "\\" ~ ("\"" | "\'" | "\\" | "/" | "b" | "f" | "n" | "r" | "t" | "u")
}

filter_spec = { (
filter_group
| filter_rev
| filter_join
| filter_replace
| filter_squash
| filter_presub
Expand All @@ -38,12 +43,22 @@ filter_noarg = { CMD_START ~ cmd }
filter_rev = {
CMD_START ~ "rev" ~ "("
~ NEWLINE*
~ (argument ~ filter_spec)?
~ (CMD_SEP+ ~ (argument ~ filter_spec))*
~ (rev ~ filter_spec)?
~ (CMD_SEP+ ~ (rev ~ filter_spec))*
~ NEWLINE*
~ ")"
}

filter_join = {
CMD_START ~ "join" ~ "("
~ NEWLINE*
~ (rev ~ filter_spec)?
~ (CMD_SEP+ ~ (rev ~ filter_spec))*
~ NEWLINE*
~ ")"
}


filter_replace = {
CMD_START ~ "replace" ~ "("
~ NEWLINE*
Expand All @@ -56,14 +71,12 @@ filter_replace = {
filter_squash = {
CMD_START ~ "squash" ~ "("
~ NEWLINE*
~ (argument ~ ":" ~ string)?
~ (CMD_SEP+ ~ (argument ~ ":" ~ string))*
~ (rev ~ ":" ~ string)?
~ (CMD_SEP+ ~ (rev ~ ":" ~ string))*
~ NEWLINE*
~ ")"
}

argument = { string | PATH }

cmd = { ALNUM+ }

file_entry = { dst_path ~ "=" ~ filter_spec }
Expand Down
Loading

0 comments on commit 7b72a8e

Please sign in to comment.