From 05e355d383f1cf01e0e7f8d7ea9c53f6d6796394 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Wed, 2 Mar 2022 03:53:04 -0400 Subject: [PATCH 1/3] meson: append git commit if possible and to non release builds --- meson.build | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index aec0cdb1..2f26305d 100644 --- a/meson.build +++ b/meson.build @@ -9,13 +9,35 @@ project('lite-xl', ] ) +#=============================================================================== +# Project version including git commit if possible +#=============================================================================== +version = meson.project_version() + +if get_option('buildtype') != 'release' + git_command = find_program('git', required : false) + + if git_command.found() + git_branch = run_command( + [git_command, 'branch', '--show-current'] + ).stdout().strip() + git_commit = run_command( + [git_command, 'rev-parse', git_branch] + ).stdout().strip() + + if git_commit != '' + version += ' (git-' + git_commit.substring(0, 8) + ')' + endif + endif +endif + #=============================================================================== # Configuration #=============================================================================== conf_data = configuration_data() conf_data.set('PROJECT_BUILD_DIR', meson.current_build_dir()) conf_data.set('PROJECT_SOURCE_DIR', meson.current_source_dir()) -conf_data.set('PROJECT_VERSION', meson.project_version()) +conf_data.set('PROJECT_VERSION', version) #=============================================================================== # Compiler Settings From 1e765b5c28b5b7c3bcd47855ac22e094514dddd5 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Wed, 2 Mar 2022 03:55:03 -0400 Subject: [PATCH 2/3] EmptyView: handle lite-xl version strings that overlap. --- data/core/emptyview.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/data/core/emptyview.lua b/data/core/emptyview.lua index 9d375c20..36ba8fb7 100644 --- a/data/core/emptyview.lua +++ b/data/core/emptyview.lua @@ -8,8 +8,18 @@ local function draw_text(x, y, color) local th = style.big_font:get_height() local dh = 2 * th + style.padding.y * 2 local x1, y1 = x, y + (dh - th) / 2 - x = renderer.draw_text(style.big_font, "Lite XL", x1, y1, color) - renderer.draw_text(style.font, "version " .. VERSION, x1, y1 + th, color) + local xv = x1 + local title = "Lite XL" + local version = "version " .. VERSION + local title_width = style.big_font:get_width(title) + local version_width = style.font:get_width(version) + if version_width > title_width then + version = VERSION + version_width = style.font:get_width(version) + xv = x1 - (version_width - title_width) + end + x = renderer.draw_text(style.big_font, title, x1, y1, color) + renderer.draw_text(style.font, version, xv, y1 + th, color) x = x + style.padding.x renderer.draw_rect(x, y, math.ceil(1 * SCALE), dh, color) local lines = { From a587182982702c58efba6c796c0387e2ebd10fb4 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Wed, 2 Mar 2022 18:55:46 -0400 Subject: [PATCH 3/3] meson: when running git rev-parse use HEAD instead of checking current branch name --- meson.build | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 2f26305d..3821e24c 100644 --- a/meson.build +++ b/meson.build @@ -18,11 +18,8 @@ if get_option('buildtype') != 'release' git_command = find_program('git', required : false) if git_command.found() - git_branch = run_command( - [git_command, 'branch', '--show-current'] - ).stdout().strip() git_commit = run_command( - [git_command, 'rev-parse', git_branch] + [git_command, 'rev-parse', 'HEAD'] ).stdout().strip() if git_commit != ''