`source .` v.s. `source <url>`

I’m try to build snap with github actions, but with source . in snapcraft.yaml I can’t get git tag information, while source <url> has no problem.

What’s the difference of source . and source url?

1 Like

Hi ! @yelf .

When you do that :
source : .

That means the location of your project directory is in the same directory of your configuration file (*.yaml ).

For the URL, you should show your *.yaml configuration file for a more informed answer.

2 Likes

Ok, I’ll provide more detail here.

The snapcraft.yaml is under snap folder in my github repository, and the build part is like this

parts:
  yazi:
    plugin: rust
    source: .
    override-build: |
      craftctl default
      echo $(git describe --tags --abbrev=0)
      ls -alh
      ....

I can saw the .git folder exist, but can’t get tag information. while the following code can get tag without problem.

parts:
  yazi:
    plugin: rust
    source: <url_of_the_repository>.git
    override-build: |
      craftctl default
      echo $(git describe --tags --abbrev=0)
      ....

There is a source-type option you can set, perhaps it’ll pick up the right bits with source: . if you set it to “git”

No, I tried, still get fatal: No names found, cannot describe anything.

What source . did to the git repository, except copy all the files?

@yelf , for the URL you should have something like this (do not forget to precise the real github link).

That’s just an example

name: ephemeral
version: '1.0'
summary: Ephemeral summary
description: |
  Ephemeral description.

grade: stable
confinement: strict

base: core18

parts:
  ephemeral:
    source: https://github.com/ephemeral/ephemeral.git
    source-type: git
    plugin: rust
    build-packages:
      - build-essential # To be sure that, all dependencies needed to compile the project are present
    stage-packages:
      - libssl-dev  # That could be a necessary package for `rust` 

In this sense, snapcraft will use the link provided via the source property to download the source of your project(the root directory of your git repository).

@baldeuniversel sorry, I may not make clear what the question is.

I have no problem with building the snap, and as I said, with source <url> everything work fine. What I don’t understand is why source . didn’t work.

What source . did to the git repository under the hood, Is this behavior a bug or intentionally?

That depends a lot of parameters .

If the source of your project (the root directory) does not exist in the same directory than you *.yaml file, an error can be raised due to missing files.

When you use the property source: . 'make sure that, the root directory of your project is already present in the same directory as your configuration file *yaml.

As I said, the snapcraft.yaml is under snap folder in my github repository(the root directory of my project), and with ls I can see all files are copied , including .git. The following is the output of github action when building the snap:

I’m totally fine with the building process, the snap can be built without problem with my setup if I set the version manually.

The only problem is I can’t get the tag information with source ., and I want to know why.

1 Like

source: . means here .

I do not see your *.yaml file .

1 Like

the .yaml is under snap folder(snap/snapcraft.yaml), I think this is quiet common setup. And the screenshot is the output of github action when building the snap, which means snapcraft can handle it properly: it can find and copy all files under my repository, it can build the snap without problem (if I set the version manually).

Especially, I can see the .git folder exist, which should contain all my repository information if I understand correct. But I can’t get the git tag information, and I don’t understand why.

In this sense try like this :

source : ..

Sorry if I did not understand the scope of the question.

I do not understand what you mean by the git tag information .

with source: .. it can’t even pull the source.

There is nothing wrong with source: ., as I said snapcraft can handle it properly even if the .yaml is under snap folder, it can find and pull the source correctly, it can build the snap without any problem.

The only problem is I can’t get the git tag info, which could be used for setting the version of snap package automatically.

by git tag information I means git describe --tags --abbrev=0 should return the current tag of my git repository, e.g. v0.1.5, with the following config:

parts:
  yazi:
    plugin: rust
    source: .
    override-build: |
      craftctl default
      # craftctl set version=$(git describe --tags --abbrev=0)
      echo $(git describe --tags --abbrev=0)
      ls -alh
      ....

But in reality I get fatal: No names found, cannot describe anything. I’m trying to figure out why.

Okay, I see.

The error fatal: No names found, cannot describe anything. means that, git cannot find any tags in your repository that can be reachable from the commit you are trying to describe.

Did you push your tags ?

I think, via the command :

git push --tags

I know the tags exist, and can be get without problem if I replace source: . with source: <url_of_the_repository>.git.

The only difference is source . v.s. source <url>. So there should be nothing wrong with my repository or my config.

The only explaination I can think of is source . did something under the hood inadvertently or intentionally, lead to the missing of git tag information.

Can I have the return of the command (from your root project) ?

git branch -v

You can also verify if the local branch has the same hash than the remote one (via git diff …).

with source: .

with source: <url_of_the_repository>.git.

Actually, I don’t really have local repository, all my test are done on github with github actions. :sweat_smile: