Skip to content

Commit

Permalink
meson.build: ensure the project git directory is used
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Skowronek <[email protected]>
  • Loading branch information
0x5a17ed committed Jun 3, 2024
1 parent 206e18f commit 733c266
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
4 changes: 0 additions & 4 deletions ci/isdir.py

This file was deleted.

19 changes: 9 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,26 @@ prefix = get_option('prefix')
localedir = get_option('localedir')

# Helper scripts
auxdir = join_paths(meson.current_source_dir(), 'ci')
isdir = join_paths(auxdir, 'isdir.py')

python3 = find_program('python3')
git = find_program('git', required: false)
git = find_program('git', required: false)

# Get the right version
fs = import('fs')

is_git_repo = run_command([isdir, '.git'], check: false).returncode() == 0
git_dir = join_paths(meson.current_source_dir(), '.git')
is_git_repo = fs.exists(git_dir)

version = 'v' + meson.project_version()
if git.found() and is_git_repo
git_version = run_command([git.full_path(), 'describe', '--dirty', '--tags'], check: false).stdout().strip()
branch = run_command([git.full_path(), 'rev-parse', '--abbrev-ref', 'HEAD'], check: false).stdout().strip()
git_version = run_command([git.full_path(), '--git-dir', git_dir, 'describe', '--dirty', '--tags'], check: false).stdout().strip()
branch = run_command([git.full_path(), '--git-dir', git_dir, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false).stdout().strip()
if branch == 'HEAD'
branch = run_command([git.full_path(), 'rev-parse', 'HEAD'], check: false).stdout().strip()
branch = run_command([git.full_path(), '--git-dir', git_dir, 'rev-parse', 'HEAD'], check: false).stdout().strip()
endif
if git_version != ''
version = git_version
endif
if branch != 'master'
default_branch = run_command([git.full_path(), '--git-dir', git_dir, 'config', '--default', 'master', '--get', 'init.defaultBranch']).stdout().strip()
if branch != default_branch
version = '@0@ (@1@)'.format(version, branch)
endif
endif
Expand Down

0 comments on commit 733c266

Please sign in to comment.