alire-project / alire

Command-line tool from the Alire project and supporting library
GNU General Public License v3.0
278 stars 49 forks source link

alr publish does not work anymore in a git submodule #1021

Closed stcarrez closed 2 years ago

stcarrez commented 2 years ago

The alr publish was working well when running in a git submodule.

This is not the case anymore at its crashes:

ciceron@zebulon:/src/awa/ada-awa/ada-util$ alr -d publish
✓ Local repository is clean.
ⓘ Crate at /src/awa/ada-awa/ada-util is nested in repo at /src/awa/ada-awa/.git/modules/ada-util
stderr: ADA.IO_EXCEPTIONS.USE_ERROR
stderr: directory "/" has no containing directory
stderr: raised ADA.IO_EXCEPTIONS.USE_ERROR : directory "/" has no containing directory
[/opt/applications/gnat-2021/bin/alr]
0xee680c ada__directories__containing_directory at ???
0xd3fdf5 Alire.Vcss.Git.Get_Rel_Path_Inside_Repo at alire-vcss-git.adb:570
0xb1644a Alire.Publish.Local_Repository.Check_Nested_Crate at alire-publish.adb:990
0xb13b0e Alire.Publish.Local_Repository at alire-publish.adb:1021
0x4b483b Alr.Commands.Publish.Execute at alr-commands-publish.adb:56
0x52a7eb Alr.Commands.Sub_Cmd.Execute at clic-subcommand-instance.adb:741
0x535d71 Alr.Commands.Execute at alr-commands.adb:492
0x42b9aa Alr.Main at alr-main.adb:10
0x42e277 Main at b__alr-main.adb:2132
[/lib/x86_64-linux-gnu/libc.so.6]
0x7f13f101b0b1
[/opt/applications/gnat-2021/bin/alr]
0x42b88c _start at ???
0xfffffffffffffffe

error: directory "/" has no containing directory
error: alr encountered an unexpected error, re-run with -d for details.

The root cause is the commit 26c5c286fd9a865ad0101710cc34e9b9ae0852c0 which introduced the Get_Rel_Path_Inside_Repo function that now fails.

I think the logic behind its use is not correct because for a submodule, you will get a different path:

ciceron@zebulon:/src/awa/ada-awa/ada-util$ git worktree list
/src/awa/ada-awa/.git/modules/ada-util  2def17d [master]

and the git repository is not in the same sub-tree as the sources.

The old logic in alr 1.1 is working very well.

mosteo commented 2 years ago

Thanks for the report and the diagnosis, Stephane.