Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mode: git-local not having any impact #88

Open
Ekion-1 opened this issue Jun 3, 2020 · 9 comments
Open

mode: git-local not having any impact #88

Ekion-1 opened this issue Jun 3, 2020 · 9 comments

Comments

@Ekion-1
Copy link

Ekion-1 commented Jun 3, 2020

I'm trying to use the git sha for the commit number by changing mode: git-local, but when I call php artisan version I get APP version 1.0.0 (commit 100001) instead of the sha. What am I doing wrong?

According to the documentation, I should run php artisan version:refresh but I get a command not defined error.

mode: 'absorb' # or 'increment'
blade-directive: version
current:
  label: v
  major: 1
  minor: 0
  patch: 0
  prerelease:
  buildmetadata:
  commit: 100001
  timestamp:
    mode: absorb
    year:
    month:
    day:
    hour:
    minute:
    second:
    timezone:
commit:
  mode: git-local
  length: 6
  increment-by: 1
git:
  from: 'local' # or "remote"
  commit:
    local: 'git rev-parse --verify HEAD'
    remote: 'git ls-remote {$repository}'
  branch: refs/heads/master
  repository: '' ### you can use config() to get it here: {{ config('version.git.remote.repository') }}. Do not use env()
  version:
    local: 'git describe'
    remote: 'git ls-remote {$repository} | grep tags/ | grep -v {} | cut -d / -f 3 | sort --version-sort | tail -1'
    matcher: '/^(?P<label>[v|V]*[er]*[sion]*)[\.|\s]*(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/'
  timestamp:
    local: 'git show -s --format=%ci'
    remote: 'git show -s --format=%ci origin/master' ## we will have to find a better way
format:
  regex:
    optional_bracket: '\[(?P<prefix>.*?)(?P<spaces>\s*)(?P<delimiter>\?\=)(?P<optional>.*?)\]'
  label: "{$label}"
  major: "{$major}"
  minor: "{$minor}"
  patch: "{$patch}"
  prerelease: "{$prerelease}"
  buildmetadata: "{$buildmetadata}"
  commit: "{$commit}"
  version: 'version {$major}.{$minor}.{$patch} (commit {$commit})'
  version-only: 'version {$major}.{$minor}.{$patch}'
  ## Bracket enclosed expressions "[.?{$variable}]" are only rendered if the ?={$variable} is filled
  full: '{$version-only}[.?={$prerelease}][+?={$buildmetadata}] (commit {$commit})'
  compact: "v{$major}.{$minor}.{$patch}-{$commit}"
  timestamp-year: '{$timestamp.year}'
  timestamp-month: '{$timestamp.month}'
  timestamp-day: '{$timestamp.day}'
  timestamp-hour: '{$timestamp.hour}'
  timestamp-minute: '{$timestamp.minute}'
  timestamp-second: '{$timestamp.second}'
  timestamp-timezone: '{$timestamp.timezone}'
  timestamp-datetime: '{$timestamp.year}-{$timestamp.month}-{$timestamp.day} {$timestamp.hour}:{$timestamp.minute}:{$timestamp.second}'
  timestamp-full: '{$timestamp.year}-{$timestamp.month}-{$timestamp.day} {$timestamp.hour}:{$timestamp.minute}:{$timestamp.second} {$timestamp.timezone}'
  ## add as many formats as you need !!!!
@Ekion-1 Ekion-1 closed this as completed Jun 3, 2020
@Ekion-1 Ekion-1 reopened this Jun 3, 2020
@jortgies
Copy link

jortgies commented Jul 6, 2020

changing

commit:
  mode: git-local
  length: 6
  increment-by: 1

to

commit:
  mode: absorb
  length: 6
  increment-by: 1

fixed this for me

@vincemukiiri
Copy link

I'm having the same issue and the solution above doesn't work

@kajluss
Copy link

kajluss commented Jul 13, 2020

I have same problem. I have no idea how can i get commit hash from local / remote git repo. I'm attaching my config code below

mode: 'absorb' # or 'increment'
blade-directive: version
current:
  label: v
  major: 1
  minor: 0
  patch: 0
  prerelease:
  buildmetadata:
  commit: 100001
  timestamp:
    mode: absorb
    year:
    month:
    day:
    hour:
    minute:
    second:
    timezone:
commit:
  mode: absorb
  length: 6
  increment-by: 1
git:
  from: 'local' # or "remote"
  commit:
    local: 'git rev-parse --verify HEAD'
    remote: 'git ls-remote {$repository}'
  branch: refs/heads/master
  repository: '' ### you can use config() to get it here: {{ config('version.git.remote.repository') }}. Do not use env()
  version:
    local: 'git describe'
    remote: 'git ls-remote {$repository} | grep tags/ | grep -v {} | cut -d / -f 3 | sort --version-sort | tail -1'
    matcher: '/^(?P<label>[v|V]*[er]*[sion]*)[\.|\s]*(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/'
  timestamp:
    local: 'git show -s --format=%ci'
    remote: 'git show -s --format=%ci origin/master' ## we will have to find a better way
format:
  regex:
    optional_bracket: '\[(?P<prefix>.*?)(?P<spaces>\s*)(?P<delimiter>\?\=)(?P<optional>.*?)\]'
  label: "{$label}"
  major: "{$major}"
  minor: "{$minor}"
  patch: "{$patch}"
  prerelease: "{$prerelease}"
  buildmetadata: "{$buildmetadata}"
  commit: "{$commit}"
  version: 'version {$major}.{$minor}.{$patch} (commit {$commit})'
  version-only: 'version {$major}.{$minor}.{$patch}'
  ## Bracket enclosed expressions "[.?{$variable}]" are only rendered if the ?={$variable} is filled
  full: '{$version-only}[.?={$prerelease}][+?={$buildmetadata}] (commit {$commit})'
  compact: "v{$major}.{$minor}.{$patch}-{$commit}"
  timestamp-year: '{$timestamp.year}'
  timestamp-month: '{$timestamp.month}'
  timestamp-day: '{$timestamp.day}'
  timestamp-hour: '{$timestamp.hour}'
  timestamp-minute: '{$timestamp.minute}'
  timestamp-second: '{$timestamp.second}'
  timestamp-timezone: '{$timestamp.timezone}'
  timestamp-datetime: '{$timestamp.year}-{$timestamp.month}-{$timestamp.day} {$timestamp.hour}:{$timestamp.minute}:{$timestamp.second}'
  timestamp-full: '{$timestamp.year}-{$timestamp.month}-{$timestamp.day} {$timestamp.hour}:{$timestamp.minute}:{$timestamp.second} {$timestamp.timezone}'
  ## add as many formats as you need !!!!

@jortgies
Copy link

are you using the latest version (1.2.2) of this package? there were some changes to the absorb feature recently

@kajluss
Copy link

kajluss commented Jul 13, 2020

are you using the latest version (1.2.2) of this package? there were some changes to the absorb feature recently

Yes, i am using latest version 1.2.2. Unfortunately with no success :( Can we contact directly? I hope that we can resolve that issue and help others with same trouble here.

@antonioribeiro
Copy link
Owner

You should all be using git absorb. The idea is the same, it will get the commit sha from your last commit, but the main difference is that you will be referring to the previous commit version. What I usually do is to use a git post-commit hook to absorb and create a commit just for the version with the message "Updated version to x.xx.xx (sha)".

Too much people had problems running git-local directly, not only problems performance problems due to the app executing git too many times, but sometimes the result not being the expected one.

We are using this package to clear some cache every time the version changes, so the version cannot be cached and it must be very fast, because it's happening on every request to the app.

I would gladly accept any PR's that could fix things, if we really have any bugs here, because git-local was not removed from the package.

@cja-github
Copy link

I'm using the latest version. When I run php artisan version:absorb I get Not in absorb mode, please edit your config file.

What am I doing wrong?

Here's my config file:

mode: 'absorb' # or 'increment'
blade-directive: version
current:
  label: v
  major: 1
  minor: 0
  patch: 0
  prerelease:
  buildmetadata:
  commit: 100001
  timestamp:
    mode: absorb
    year:
    month:
    day:
    hour:
    minute:
    second:
    timezone:
commit:
  mode: absorb
  length: 6
  increment-by: 1
git:
  from: 'local' # or "remote"
  commit:
    local: 'git rev-parse --verify HEAD'
    remote: 'git ls-remote {$repository}'
  branch: refs/heads/master
  repository: '' ### you can use config() to get it here: {{ config('version.git.remote.repository') }}. Do not use env()
  version:
    local: 'git describe'
    remote: 'git ls-remote {$repository} | grep tags/ | grep -v {} | cut -d / -f 3 | sort --version-sort | tail -1'
    matcher: '/^(?P<label>[v|V]*[er]*[sion]*)[\.|\s]*(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/'
  timestamp:
    local: 'git show -s --format=%ci'
    remote: 'git show -s --format=%ci origin/master' ## we will have to find a better way
format:
  regex:
    optional_bracket: '\[(?P<prefix>.*?)(?P<spaces>\s*)(?P<delimiter>\?\=)(?P<optional>.*?)\]'
  label: "{$label}"
  major: "{$major}"
  minor: "{$minor}"
  patch: "{$patch}"
  prerelease: "{$prerelease}"
  buildmetadata: "{$buildmetadata}"
  commit: "{$commit}"
  version: 'version {$major}.{$minor}.{$patch} (commit {$commit})'
  version-only: 'version {$major}.{$minor}.{$patch}'
  ## Bracket enclosed expressions "[.?{$variable}]" are only rendered if the ?={$variable} is filled
  full: '{$version-only}[.?={$prerelease}][+?={$buildmetadata}] (commit {$commit})'
  compact: "v{$major}.{$minor}.{$patch}-{$commit}"
  timestamp-year: '{$timestamp.year}'
  timestamp-month: '{$timestamp.month}'
  timestamp-day: '{$timestamp.day}'
  timestamp-hour: '{$timestamp.hour}'
  timestamp-minute: '{$timestamp.minute}'
  timestamp-second: '{$timestamp.second}'
  timestamp-timezone: '{$timestamp.timezone}'
  timestamp-datetime: '{$timestamp.year}-{$timestamp.month}-{$timestamp.day} {$timestamp.hour}:{$timestamp.minute}:{$timestamp.second}'
  timestamp-full: '{$timestamp.year}-{$timestamp.month}-{$timestamp.day} {$timestamp.hour}:{$timestamp.minute}:{$timestamp.second} {$timestamp.timezone}'
  ## add as many formats as you need !!!!

@vbasky
Copy link

vbasky commented Jul 6, 2021

I am having the same issue. Nothing seems to be working based on the default configuration to set the commit number as the version.

@AmraniCh
Copy link

same problem here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants