Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the status of git submodules when checking if a repository is up-to-date #6153

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading