rattler-build icon indicating copy to clipboard operation
rattler-build copied to clipboard

`git.latest_tag` doesn't support relative paths

Open garymm opened this issue 1 year ago • 2 comments

Putting:

source:
  path: ../

Works fine, and I'm using this in my recipe.

However, this does not work to get the tag:

context:
  version: ${{ git.latest_tag("../") }}

I've tried several variants:

  • ../
  • ../.git
  • file://../
  • file:/../
  • file://../.git
  • file:/../.git

None of them work.

garymm avatar Jun 01 '24 03:06 garymm

I just had a look and I think we should rewrite thsi function a bit to use git for-each-ref locally (or git describe). But it's a bit tricky - especially git ls-remote doesn't allow us to sort by creatordate which would be more appropriate than sorting by 'version' inferred from the tag.

Basically the behavior is in most cases a bit ambigous. However if you run this as part of some script, you might have an easier time for now to just use an env var, e.g.

export GIT_TAG=$(git find the tag ...)

and then in the recipe you can just use

context:
  version: ${{ env.get("GIT_TAG") }}

You also don't need the --experimental flag in that case.

wolfv avatar Jun 11 '24 14:06 wolfv

I have tried using both


context:
  name: xyz
  repo_url: [email protected]
  latest_tag: ${{ git.latest_tag( repo_url ) }}
  version: ${{ latest_tag }}

package:
  name: ${{ name|lower }}
  version: ${{ latest_tag }}

and

context:
  name: xyz
  # . is the repo root relative to where I'm executing rattler-build from
  latest_tag: ${{ git.latest_tag( "." ) }}
  version: ${{ latest_tag }}

package:
  name: ${{ name|lower }}
  version: ${{ latest_tag }}

Both give me a tag name, BUT it's not the latest tag. It seems to be the first tag in alphabetical order. The actual latest tag is 0.2.5

For reference, this is what git describe --tags returns: 0.2.5-114-g119568d8

Here's all my tags with their creation date:

refs/tags/v0.0.1 Tue Mar 24 12:53:24 2020 +0000
refs/tags/v0.0.2 Tue Jun 9 13:50:09 2020 +0200
refs/tags/v0.0.3 Thu Jul 16 12:22:41 2020 +0000
refs/tags/v0.0.4 Thu Nov 5 05:59:26 2020 +0100
refs/tags/v0.0.5_jacket Mon Mar 1 10:20:43 2021 +0100
refs/tags/v0.0.5 Mon Mar 15 11:12:06 2021 +0100
refs/tags/pp_hub_dev Mon Jun 21 14:25:36 2021 +0200
refs/tags/v0.0.6 Tue Jun 22 14:41:45 2021 +0200
refs/tags/optimize_copy Fri Jul 9 14:27:48 2021 +0200
refs/tags/mayfl_wind_sea_swell Tue Oct 19 11:34:03 2021 +0000
refs/tags/v0.0.7 Wed Mar 2 12:27:11 2022 +0100
refs/tags/v0.0.8 Fri Apr 1 13:22:24 2022 +0200
refs/tags/v0.0.9 Mon Aug 15 15:15:32 2022 +0000
refs/tags/0.0.10 Tue Jul 4 14:49:58 2023 +0000
refs/tags/0.1.0 Thu Jul 20 08:19:25 2023 +0000
refs/tags/0.1.1 Tue Aug 29 07:37:56 2023 +0000
refs/tags/0.1.2 Wed Sep 13 13:17:25 2023 +0000
refs/tags/0.1.3 Thu Oct 5 07:56:35 2023 +0000
refs/tags/0.1.4 Wed Oct 25 09:37:11 2023 +0000
refs/tags/0.2.0 Tue Nov 7 14:34:35 2023 +0000
refs/tags/0.2.1 Mon Dec 18 12:44:47 2023 +0000
refs/tags/0.2.2 Fri Jan 12 13:56:48 2024 +0000
refs/tags/0.2.3 Fri Mar 15 07:43:10 2024 +0000
refs/tags/0.2.4 Tue Apr 30 12:39:03 2024 +0000
refs/tags/0.2.5 Thu Jul 4 04:41:09 2024 +0000

And here's the output of git tag

0.0.10
0.1.0
0.1.1
0.1.2
0.1.3
0.1.4
0.2.0
0.2.1
0.2.2
0.2.3
0.2.4
0.2.5
mayfl_wind_sea_swell
optimize_copy
pp_hub_dev
v0.0.1
v0.0.2
v0.0.3
v0.0.4
v0.0.5
v0.0.5_jacket
v0.0.6
v0.0.7
v0.0.8

MartinJepsen avatar Jul 20 '24 11:07 MartinJepsen