Skip to content

Commit

Permalink
Check the status of git submodules when checking if a repository is u…
Browse files Browse the repository at this point in the history
…p-to-date
  • Loading branch information
kit-ty-kate authored and rjbou committed Aug 26, 2024
1 parent 6cbdfbb commit 5dcbf48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ users)

## VCS
* Fail when git submodule fails to update instead of showing a warning and ignoring the error [#6132 @kit-ty-kate - fix #6131]
* Check the status of git submodules when checking if a repository is up-to-date [#6132 @kit-ty-kate]

## Build
* Synchronise opam-core.opam with opam-repository changes [#6043 @dra27]
Expand Down
14 changes: 13 additions & 1 deletion src/repository/opamGit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,19 @@ module VCS : OpamVCS.VCS = struct
@ List.map OpamFilename.SubPath.to_string
(OpamStd.Option.to_list subpath))
@@> function
| { OpamProcess.r_code = 0; _ } -> Done true
| { OpamProcess.r_code = 0; _ } ->
git repo_root ["submodule"; "status"; "--recursive"] @@> fun r ->
if r.r_code = 0 &&
(* NOTE: We check the first character of each lines of the output
to verify that every submodules are in their expected state.
The git submodule manual states:
Each SHA-1 will possibly be prefixed with - if the submodule is
not initialized, + if the currently checked out submodule commit
does not match the SHA-1 found in the index of the containing
repository and U if the submodule has merge conflicts. *)
List.for_all (fun s -> String.length s > 0 && s.[0] = ' ') r.r_stdout
then Done true
else (OpamProcess.cleanup ~force:true r; Done false)
| { OpamProcess.r_code = 1; _ } as r ->
OpamProcess.cleanup ~force:true r; Done false
| r -> OpamSystem.process_error r
Expand Down

0 comments on commit 5dcbf48

Please sign in to comment.