Fixes #3424.
Simple fix for now. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3578
-- Commit Summary --
* Fix meson build without git repo
-- File Changes --
M meson.build (3)
-- Patch Links --
https://github.com/geany/geany/pull/3578.patch https://github.com/geany/geany/pull/3578.diff
Agree a reasonable short term fix for 2.0 to make the tarballs buildable with meson.
See https://github.com/geany/geany/issues/3424#issuecomment-1751529720 for the git solution, and its issues.
LGBI
Can't we simply not error-out if the `git` command fails, and assume `REVISION=-1` as well then? given I see `check: true` maybe it'd be easy to change that…
given I see check: true maybe it'd be easy to change that…
Yeah, `check:false` does not fail, but returns `ret.return_code()` that can be tested for success.
I don't really want to support meson from the tarball. It's still too experimental. If it seems to work from the tarball some guy or distro is going to rely on it.
I don't really want to support meson from the tarball. It's still too experimental. If it seems to work from the tarball some guy or distro is going to rely on it.
We should definitely clearly mark this as experimental then.
But ATM it'll work from a tarball given `git` is not installed on the machine IIUC, so it's very possible especially a builder being happy about it.
@b4n commented on this pull request.
-if git.found()
+if git.found() and fs.is_dir('.git') ret = run_command(git, 'rev-parse', '--short', '--revs-only', 'HEAD', check: true) cdata.set_quoted('REVISION', ret.stdout().strip()) else
So what about something like this (untested at all, and I barely know Meson): ```meson revision = '-1' if git.found(): ret = run_command(git, 'rev-parse', '--short', '--revs-only', 'HEAD', check: false) if ret.return_code() == 0: revision = ret.stdout().strip() cdata.set_quoted('REVISION', revision) ```
@ntrel commented on this pull request.
-if git.found()
+if git.found() and fs.is_dir('.git') ret = run_command(git, 'rev-parse', '--short', '--revs-only', 'HEAD', check: true) cdata.set_quoted('REVISION', ret.stdout().strip()) else
Looks OK.
@eli-schwartz commented on this pull request.
-if git.found()
+if git.found() and fs.is_dir('.git') ret = run_command(git, 'rev-parse', '--short', '--revs-only', 'HEAD', check: true) cdata.set_quoted('REVISION', ret.stdout().strip()) else
I recommend to use `fs.exists()` since the `.git` filesystem entry can be a file, in which case the contents of the file are a single line: ``` gitdir: path/to/.git/worktrees/foobar ```
This is how `git worktree` works.
Actual diff from master that WFM: ```diff diff --git a/meson.build b/meson.build index ec3e509af..eacb73cb6 100644 --- a/meson.build +++ b/meson.build @@ -166,12 +166,14 @@ python = pymod.find_installation('python3', modules: doxygen.found() and get_opt rst2html = find_program('rst2html', required: get_option('html-docs')) rst2pdf = find_program('rst2pdf', required: get_option('pdf-docs')) git = find_program('git', required: false) +revision = '-1' if git.found() - ret = run_command(git, 'rev-parse', '--short', '--revs-only', 'HEAD', check: true) - cdata.set_quoted('REVISION', ret.stdout().strip()) -else - cdata.set_quoted('REVISION', '-1') + ret = run_command(git, 'rev-parse', '--short', '--revs-only', 'HEAD', check: false) + if ret.returncode() == 0 + revision = ret.stdout().strip() + endif endif +cdata.set_quoted('REVISION', revision)
python_command = get_option('python-command') if python_command == '' or python_command == 'auto' ```
@ntrel should I open a PR/update this one with this, do you want to take it over, do you have anything against it… ?
Submitted my version as #3597
Closed #3578.
Closing in favor to #3597.
github-comments@lists.geany.org