Open
Description
Currently, having a package that declares the following source-repository
stanza in the available repositories (hackage):
source-repository this
type: git
location: <url>
tag: <tag>
branch: <branch>
When one runs cabal get <pkg> -sthis -d<somedir>
will perform the following sequence of commands:
(cd somedir && git clone <url> --branch <branch>)
if [ -n <tag> ]; then
(cd somedir/pkg && git reset --hard <tag> --)
fi
(cd somedir/pkg && git submodule sync --recursive)
(cd somedir/pkg && git submodule update --init --force --recursive)
I would argue that the git reset
is just wrong. It will reset whichever branch was cloned to the tag, resulting in a state that disagrees with the git server. My proposal is as follows:
branch
andtag
should be exclusive. To be precise, they could be merged into either of them or some new name. Either way, only one of those has to/should be provided. Probablyref
orrev
would be a good name.- Invoke
git clone <url> --branch <branch-or-tag>
as git can handle tags in that argument. - As a side improvement, the directory provided in
-d
should be used as the output directory, and not as a parent folder for the clone. This means that usingcabal get <pkg> -sthis -d<somedir>
will clone the repo in./somedir
and not in./somedir/reponame
. This can be achieved by invokinggit clone --branch <branch-or-tag> <url> <somedir>
Note that the same reasoning could apply to source-repository-package
as those also allow for branch
and tag
.