Skip to content

Commit fd8bd0e

Browse files
fix small bugs
1 parent 21c3ad4 commit fd8bd0e

File tree

3 files changed

+41
-45
lines changed

3 files changed

+41
-45
lines changed

commitinfo

Lines changed: 0 additions & 1 deletion
This file was deleted.

gitCommit/gitrevision.lua

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,56 @@ local log = require("hg.log")
22

33
local M = {}
44

5-
local COMMIT_INFO_PATH = "gitcommit/commitinfo"
5+
local COMMIT_INFO_PATH = "commitinfo"
66
local REVISION_LENGTH = 10
77

88
local function read_commit_hash()
9-
local file, open_error = io.open(COMMIT_INFO_PATH, "r")
10-
11-
if not file then
12-
log.debug(
13-
string.format(
14-
"WARNING: Failed to open commit information file: %s (%s)",
15-
COMMIT_INFO_PATH,
16-
open_error or "unknown error"
17-
)
18-
)
19-
return nil
20-
end
21-
22-
local revision = file:read("*l")
23-
file:close()
24-
25-
if not revision or revision == "" then
26-
log.debug("WARNING: Commit information file is empty or unreadable: " .. COMMIT_INFO_PATH)
27-
return nil
28-
end
29-
30-
return revision:sub(1, REVISION_LENGTH)
9+
local file, open_error = io.open(COMMIT_INFO_PATH, "r")
10+
11+
if not file then
12+
log.debug(
13+
string.format(
14+
"WARNING: Failed to open commit information file: %s (%s)",
15+
COMMIT_INFO_PATH,
16+
open_error or "unknown error"
17+
)
18+
)
19+
return nil
20+
end
21+
22+
local revision = file:read("*l")
23+
file:close()
24+
25+
if not revision or revision == "" then
26+
log.debug("WARNING: Commit information file is empty or unreadable: " .. COMMIT_INFO_PATH)
27+
return nil
28+
end
29+
30+
return revision:sub(1, REVISION_LENGTH)
3131
end
3232

3333
function M.apply_revision_override()
34-
local revision = read_commit_hash()
34+
local revision = read_commit_hash()
3535

36-
if not revision then
37-
log.debug("INFO: project.revision override will not be applied.")
38-
return
39-
end
36+
if not revision then
37+
log.debug("INFO: project.revision override will not be applied.")
38+
return
39+
end
4040

41-
log.debug("INFO: Detected commit hash: " .. revision .. ". Overriding sys.get_config.")
41+
log.debug("INFO: Detected commit hash: " .. revision .. ". Overriding sys.get_config.")
4242

43-
local original_get_config = sys.get_config
43+
local original_get_config = sys.get_config
4444

45-
sys.get_config = function(key, default_value)
46-
if key == "project.revision" then
47-
return revision
48-
end
49-
return original_get_config(key, default_value)
50-
end
45+
sys.get_config = function(key, default_value)
46+
if key == "project.revision" then
47+
return revision
48+
end
49+
return original_get_config(key, default_value)
50+
end
5151

52-
log.debug(
53-
"INFO: sys.get_config successfully overridden. project.revision is now: " .. sys.get_config("project.revision")
54-
)
52+
log.debug(
53+
"INFO: sys.get_config successfully overridden. project.revision is now: " .. sys.get_config("project.revision")
54+
)
5555
end
5656

57-
return M
57+
return M

src/gitcommit.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@
88
#include <assert.h>
99

1010
static char s_commit_hash[11] = {0};
11-
static const char* COMMIT_FILE_PATH = "gitcommit/commitinfo";
11+
static const char* COMMIT_FILE_PATH = "commitinfo";
1212

1313
static void RetrieveGitCommit() {
14-
#if !defined(_WIN32) && !defined(_WIN64)
15-
system("mkdir -p gitcommit");
16-
#endif
1714
char cmd[256];
1815
#if defined(_WIN32) || defined(_WIN64)
1916
snprintf(cmd, sizeof(cmd),

0 commit comments

Comments
 (0)