version
version copied to clipboard
`mode: git-local` not having any impact
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 !!!!
changing
commit:
mode: git-local
length: 6
increment-by: 1
to
commit:
mode: absorb
length: 6
increment-by: 1
fixed this for me
I'm having the same issue and the solution above doesn't work
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 !!!!
are you using the latest version (1.2.2) of this package? there were some changes to the absorb feature recently
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.
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.
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 !!!!
I am having the same issue. Nothing seems to be working based on the default configuration to set the commit number as the version.
same problem here!