File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
src/handlers/check_commits Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 1
1
use std:: sync:: LazyLock ;
2
2
3
- use regex:: Regex ;
3
+ use regex:: { Regex , RegexBuilder } ;
4
4
5
5
use crate :: github:: FileDiff ;
6
6
7
7
const SUBMODULE_WARNING_MSG : & str = "Some commits in this PR modify **submodules**." ;
8
8
9
- static SUBPROJECT_UPDATE_RE : LazyLock < Regex > =
10
- LazyLock :: new ( || Regex :: new ( r"\+Subproject\scommit\s" ) . unwrap ( ) ) ;
9
+ static SUBPROJECT_COMMIT_RE : LazyLock < Regex > = LazyLock :: new ( || {
10
+ RegexBuilder :: new ( r"^\+Subproject commit [a-zA-Z0-9]+$" )
11
+ . multi_line ( true )
12
+ . build ( )
13
+ . unwrap ( )
14
+ } ) ;
11
15
12
16
/// Returns a message if the PR modifies a git submodule.
13
17
pub ( super ) fn modifies_submodule ( diff : & [ FileDiff ] ) -> Option < String > {
14
18
if diff
15
19
. iter ( )
16
- . any ( |fd| SUBPROJECT_UPDATE_RE . is_match ( & fd. patch ) )
20
+ . any ( |fd| SUBPROJECT_COMMIT_RE . is_match ( & fd. patch ) )
17
21
{
18
22
Some ( SUBMODULE_WARNING_MSG . to_string ( ) )
19
23
} else {
@@ -61,6 +65,5 @@ fn no_submodule_update_tricky_case() {
61
65
. to_string ( ) ,
62
66
} ;
63
67
64
- // FIXME: This should be true (aka None), but isn't currently!
65
68
assert_eq ! ( modifies_submodule( & [ filediff] ) , None )
66
69
}
You can’t perform that action at this time.
0 commit comments