Git clone with --depth=1 loses the tags

Bug #1617783 reported by Mark Shuttleworth
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
Medium
Sergio Schvezov

Bug Description

I have a part which is failing because the upstream uses tags in the git tree explicitly as part of the build process. THe snapcraft clone however uses --depth=1 which means those tags are lost.

We should by default clone the entire git repository. A snapcraft part should be able to specify a shallow clone by providing an explicit depth.

Can we make it so you can specify 'source-depth: n' in the part specification if you want a shallow clone (typically n would be 1) but that otherwise snapcraft will by default omit the depth and make a full clone of the repository?

Tags: sources
Revision history for this message
Leo Arias (elopio) wrote :

Can you please share your yaml or repo?

tags: added: sources
Changed in snapcraft:
status: New → Incomplete
Revision history for this message
Mark Shuttleworth (sabdfl) wrote :

Here is a tgz of my snapcraft.yaml and a new plugin that I would ask you to land in snapcraft on my behalf :P

Leo Arias (elopio)
Changed in snapcraft:
importance: Undecided → Medium
status: Incomplete → Triaged
Revision history for this message
Leo Arias (elopio) wrote :

The problem is easy to reproduce with the attached project. And removing the --depth argument results in a usable snap. Thanks.

For the record, about the plugin to run a shell command we are having a discussion in https://github.com/snapcore/snapcraft/pull/727.

And a note for Sergio: there is a common pattern for go projects: set the GOPATH, and then run a command, usually Make. If the part could set somehow the environment variable, many many projects would be dead-simple to snap.

Revision history for this message
Sergio Schvezov (sergiusens) wrote : Re: [Bug 1617783] Re: Git clone with --depth=1 loses the tags

El 02/09/16 a las 14:54, Leo Arias escribió:
> The problem is easy to reproduce with the attached project. And removing
> the --depth argument results in a usable snap. Thanks.
>
> For the record, about the plugin to run a shell command we are having a
> discussion in https://github.com/snapcore/snapcraft/pull/727.
>
> And a note for Sergio: there is a common pattern for go projects: set
> the GOPATH, and then run a command, usually Make. If the part could set
> somehow the environment variable, many many projects would be dead-
> simple to snap.

This is in the roadmap
https://trello.com/c/0HceL08Y/168-snapcraft-third-party-java-with-parts-14-30-15-30
and
https://trello.com/c/0vnzNOtK/160-build-environment-and-environment-from-parts

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

@sabdfl I strongly believe we should shallow clone by default and allow full clones as an opt-in. The only reason a clone from a part you depend on (which is not the project you are working on but a piece of the integration puzzle to build your product) is because the build system is tied into a VCS. Can we go with the simple route of not even exposing depth but a knob such as

    source-attributes: [shallow]

or

    source-shallow: <on|off>

The former allows for easier expansion and sort of keeps things declarative.
I call it `shallow` so we can have a common language for all VCS's

Revision history for this message
Mark Shuttleworth (sabdfl) wrote :

Most docs say "git clone" not "git clone depth=...." and I think
snapcraft should follow that unless the snapcraft.yaml author
consciously CHOOSES otherwise. Let the person who knows the git repo
decide this, not us by guesstimate.

I got bit by this on snap #3, I imagine others will too, 'git describe'
seems like common practice (I have another snap which builds but then
its internal version is 'unknown on unknown commit" so I suspect this
issue is more widespread than you think.

Thank,
Mark

Changed in snapcraft:
status: Triaged → In Progress
milestone: none → 2.18
assignee: nobody → Sergio Schvezov (sergiusens)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Changed in snapcraft:
status: In Progress → Fix Committed
Revision history for this message
Mark Shuttleworth (sabdfl) wrote :

Thank you :)

Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.