source-tag attempts to clone branch, fails

Bug #1724526 reported by Stuart Bishop
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Invalid
Undecided
Unassigned

Bug Description

Attempting to build a tagged revision from a git repo fails, as snapcraft treats the tag as a branch and the clone fails attempting to clone a branch that does not exist. The exact same error is seen using source-branch, which indicates snapcraft is treating source-tag and source-branch as interchangable where in this particular case they are not.

While you are there, git clone is very likely to fail so catching the CalledProcessError and printing an error more readable than a traceback would be a usability win.

name: schemaspy
version: 6.0.0-rc2
summary: SchemaSpy database documentation generation
description: >
  SchemaSpy is a tool that analyzes the metadata of a schema in a database
  and generates a visual representation of it in a browser-displayable
  format. It lets you click through the hierarchy of database tables
  via child and parent table relationships as represented by both HTML
  links and entity-relationship diagrams. It’s also designed to help
  resolve the obtuse errors that a database sometimes gives related to
  failures due to constraints. It is free software that is distributed
  under the terms of the MIT License.
grade: stable
confinement: strict
apps:
  schemaspy:
    command: schemaspy
    plugs:
      - network
parts:
  schemaspy:
    plugin: maven
    source: https://github.com/schemaspy/schemaspy.git
    source-type: git
    source-tag: 6.0.0-rc2

Fails with:

Pulling schemaspy
Cloning into '/home/stub/snapcraft/schemaspy/parts/schemaspy/src'...
fatal: Remote branch 6.0.0-rc2 not found in upstream origin
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 9, in <module>
    load_entry_point('snapcraft==2.34', 'console_scripts', 'snapcraft')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/__main__.py", line 19, in <module>
    run(prog_name='snapcraft')
  File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1037, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/__init__.py", line 110, in run
    ctx.forward(lifecyclecli.commands['snap'])
  File "/usr/lib/python3/dist-packages/click/core.py", line 552, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/cli/lifecycle.py", line 132, in snap
    project_options, directory=directory, output=output)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 349, in snap
    execute('prime', project_options)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 130, in execute
    _Executor(config, project_options).run(step, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 225, in run
    self._run_step(step, part, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 262, in _run_step
    getattr(part, step)()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler/__init__.py", line 251, in pull
    self.source_handler.pull()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/sources/_git.py", line 145, in pull
    self._clone_new()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/sources/_git.py", line 134, in _clone_new
    **self._call_kwargs)
  File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'clone', '--recursive', '--branch', '6.0.0-rc2', 'https://github.com/schemaspy/schemaspy.git', '/home/stub/snapcraft/schemaspy/parts/schemaspy/src']' returned non-zero exit status 128

Revision history for this message
Stuart Bishop (stub) wrote :

I am using git 2.14.2 (latest stable), which may be an issue.

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

$ git clone https://github.com/schemaspy/schemaspy.git
Cloning into 'schemaspy'...
remote: Counting objects: 3570, done.
remote: Total 3570 (delta 0), reused 0 (delta 0), pack-reused 3570
Receiving objects: 100% (3570/3570), 29.24 MiB | 3.94 MiB/s, done.
Resolving deltas: 100% (1584/1584), done.
Checking connectivity... done.

$ cd schemaspy/
$ git tag
v6.0.0-beta.1
v6.0.0-beta.2
v6.0.0-beta.3
v6.0.0-rc1
v6.0.0-rc2

Try changing your `source-tag` to start with a "v".

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

Other bug subscribers

Remote bug watches

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