Skip to content

Commit bc7246a

Browse files
committed
Show git commit hash in gala --version
1 parent c1b5854 commit bc7246a

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
env:
3737
DESTDIR: out
3838
run: |
39+
git config --global --add safe.directory "$(pwd)"
3940
meson build -Ddocumentation=true -Dtests=true
4041
ninja -C build
4142
ninja -C build install
@@ -78,6 +79,7 @@ jobs:
7879
env:
7980
DESTDIR: out
8081
run: |
82+
git config --global --add safe.directory "$(pwd)"
8183
meson build
8284
ninja -C build install
8385

config.vala.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* SPDX-License-Identifier: GPL-3.0-or-later
3-
* SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io)
3+
* SPDX-FileCopyrightText: 2025-2026 elementary, Inc. (https://elementary.io)
44
* 2011 Robert Dyer
55
* 2011 Rico Tzschichholz
66
*/
@@ -10,4 +10,5 @@ namespace Config {
1010
public const string LOCALEDIR = "@LOCALEDIR@";
1111
public const string VERSION = "@VERSION@";
1212
public const string PLUGINDIR = "@PLUGINDIR@";
13+
public const string GIT_HASH = "@GIT_HASH@";
1314
}

meson.build

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ conf.set('GETTEXT_PACKAGE', meson.project_name())
2525
conf.set('LOCALEDIR', locale_dir)
2626
conf.set('PLUGINDIR', plugins_dir)
2727
conf.set('VERSION', meson.project_version())
28+
29+
git = find_program('git', required: false)
30+
git_hash = 'unknown'
31+
if git.found()
32+
git_hash = run_command(['git', 'rev-parse', '--short', 'HEAD'], capture : true, check : true).stdout().strip()
33+
endif
34+
conf.set('GIT_HASH', git_hash)
35+
2836
config_header = configure_file (
2937
input: 'config.vala.in',
3038
output: 'config.vala',

src/Main.vala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//
22
// Copyright (C) 2012 Tom Beckmann, Rico Tzschichholz
3+
// Copyright (C) 2026 elementary, Inc.
34
//
45
// This program is free software: you can redistribute it and/or modify
56
// it under the terms of the GNU General Public License as published by
@@ -22,7 +23,7 @@ namespace Gala {
2223
};
2324

2425
private void print_version () {
25-
stdout.printf ("Gala %s\n", Config.VERSION);
26+
stdout.printf ("Gala %s (%s)\n", Config.VERSION, Config.GIT_HASH);
2627
Meta.exit (Meta.ExitCode.SUCCESS);
2728
}
2829

0 commit comments

Comments
 (0)