Skip to content

Commit 2b0fa16

Browse files
authored
Merge pull request #12655 from Alizter/push-nnyvstvrsltv
fix(cram): allow text after conflict markers
2 parents 172dfbb + 0c987ca commit 2b0fa16

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

doc/changes/added/12538.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
- Add a `(conflict_markers error|ignore)` option to the cram stanza. When
22
`(conflict_markers error)` is set, the cram test will fail in the presence of
33
conflict markers. Git, diff3 and jujutsu conflict markers are detected.
4-
(#12538, #12617, fixes #12512, @rgrinberg, @Alizter)
4+
(#12538, #12617, #12655, fixes #12512, @rgrinberg, @Alizter)

src/dune_rules/cram/cram_exec.ml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ let quote_for_sh fn =
4242

4343
let cram_stanzas =
4444
let is_conflict_marker line =
45-
match line with
46-
| "=======" | "%%%%%%%" | "+++++++" | "-------" | "|||||||" -> true
47-
| _ -> false
45+
[ "======="; "%%%%%%%"; "+++++++"; "-------"; "|||||||" ]
46+
|> List.exists ~f:(fun prefix -> String.is_prefix line ~prefix)
4847
in
4948
let find_conflict state line =
5049
match state with
51-
| `No_conflict when line = "<<<<<<<" -> `Started
50+
| `No_conflict when String.is_prefix ~prefix:"<<<<<<<" line -> `Started
5251
| `Started when is_conflict_marker line -> `Has_markers
5352
| `Has_markers when is_conflict_marker line -> `Has_markers
54-
| `Has_markers when line = ">>>>>>>" ->
53+
| `Has_markers when String.is_prefix ~prefix:">>>>>>>" line ->
5554
(* CR-someday rgrinberg for alizter: insert a location spanning the
5655
entire once we start extracting it *)
5756
User_error.raise

test/blackbox-tests/test-cases/cram/conflict-markers-jj.t

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ Cram tests can forbid jujutsu conflicts:
1111
Full jujutsu conflict without command and output interleaving:
1212

1313
$ cat >test.t <<EOF
14-
> <<<<<<<
14+
> <<<<<<< Conflict 1 of 2
1515
> A Small
1616
> %%%%%%%
1717
> Conflict
18-
> >>>>>>>
18+
> >>>>>>> Conflict 1 of 2 ends
1919
> $ echo tada
2020
> EOF
2121

@@ -30,11 +30,11 @@ Full jujutsu conflict without command and output interleaving:
3030
Full jujutsu conflict with command and output interleaving:
3131

3232
$ cat >test.t <<EOF
33-
> <<<<<<<
33+
> <<<<<<< Conflict 2 of 2
3434
> $ foo
3535
> %%%%%%%
3636
> > bar
37-
> >>>>>>>
37+
> >>>>>>> Conflict 2 of 2 ends
3838
> $ echo tada
3939
> EOF
4040

@@ -49,14 +49,14 @@ Full jujutsu conflict with command and output interleaving:
4949
Jujutsu default style conflict (diff + snapshot):
5050

5151
$ cat >test.t <<EOF
52-
> <<<<<<<
53-
> %%%%%%%
52+
> <<<<<<< Conflict 1 of 1
53+
> %%%%%%% Changes from base to side #1
5454
> -apple
5555
> +grapefruit
56-
> +++++++
56+
> +++++++ Contents of side #2
5757
> APPLE
5858
> GRAPE
59-
> >>>>>>>
59+
> >>>>>>> Conflict 1 of 1 ends
6060
> $ echo tada
6161
> EOF
6262

@@ -71,14 +71,14 @@ Jujutsu default style conflict (diff + snapshot):
7171
Jujutsu snapshot style conflict:
7272

7373
$ cat >test.t <<EOF
74-
> <<<<<<<
75-
> +++++++
74+
> <<<<<<< Conflict 1 of 1
75+
> +++++++ Contents of side #1
7676
> Left side
77-
> -------
77+
> ------- Contents of base
7878
> Original
79-
> +++++++
79+
> +++++++ Contents of side #2
8080
> Right side
81-
> >>>>>>>
81+
> >>>>>>> Conflict 1 of 1 ends
8282
> $ echo tada
8383
> EOF
8484

0 commit comments

Comments
 (0)