antonioribeiro / antonioribeiro/version
package not working / trying to access array offset
- Dominant language
- PHP
- Stars
- 592
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Description
Installed the package and copied the config file:
```
root@dev:/var/www/html/proj# php artisan vendor:publish --provider="PragmaRX\Version\Package\ServiceProvider"
Copied File [/vendor/pragmarx/version/src/config/version.yml] To [/config/version.yml]
Publishing complete.
root@dev:/var/www/html/proj# php artisan version:commit
ErrorException
Trying to access array offset on value of type null
at vendor/pragmarx/version/src/package/Support/Increment.php:50
46▕ */
47▕ public function incrementCommit($by = null)
48▕ {
49▕ $result = $this->increment(function ($config) use ($by) {
➜ 50▕ $increment_by = $by ?: $config['commit']['increment-by'];
51▕
52▕ $config['current']['commit'] = $this->incrementHex($config['current']['commit'], $increment_by);
53▕
54▕ return $config;
+18 vendor frames
19 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
```
The config file itself is the plain config file, no edits made:
```
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[v|V]*[er]*[sion]*)[\.|\s]*(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?: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[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.*?)(?P\s*)(?P\?\=)(?P.*?)\]'
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 !!!!
```
The `git` folder is inside the project folder itself, default as usual.
ls -alh /var/www/html/proj/ | grep .git
drwxrwxr-x 7 dev www-data 4.0K Oct 24 12:29 .git
Any idea where things go wrong?
Running
> root@dev:/var/www/html/proj# git rev-parse --verify HEAD
abec161d268c07....
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with vendor/pragmarx/version/src/package/Support/Increment.php at line 50 and compare the parsed config used by incrementCommit() with the published config/version.yml. Run php artisan version:commit while checking that configuration path, and consider the issue resolved when the command completes without the reported array-offset exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- backend, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100