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 committed Aug 13, 2024
1 parent 0ea9e2d commit 6355212
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 @@ -81,6 +81,7 @@ users)
## Sandbox

## VCS
* 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 @@ -216,7 +216,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 6355212

Please sign in to comment.