Skip to content

Commit 5b2472c

Browse files
authored
Merge pull request #347 from jedi2light/feature-show-git-commit-hash-short
Feature: Store and show git short ref on PineTime alongside other firmware information
2 parents b588439 + a4de61e commit 5b2472c

7 files changed

Lines changed: 36 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,22 @@ if(BUILD_DFU)
5555
set(BUILD_DFU true)
5656
endif()
5757

58+
set(PROJECT_GIT_COMMIT_HASH "")
59+
60+
execute_process(COMMAND git rev-parse --short HEAD
61+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
62+
OUTPUT_VARIABLE PROJECT_GIT_COMMIT_HASH
63+
RESULT_VARIABLE PROJECT_GIT_COMMIT_HASH_SUCCESS)
64+
65+
string(STRIP ${PROJECT_GIT_COMMIT_HASH} PROJECT_GIT_COMMIT_HASH)
66+
67+
message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS})
68+
5869
message("BUILD CONFIGURATION")
5970
message("-------------------")
6071
message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
6172
message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH})
73+
message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH})
6274
message(" * NRF52 SDK : " ${NRF5_SDK_PATH})
6375
set(PROGRAMMER "???")
6476
if(USE_JLINK)

docker/.gitpod.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ RUN apt-get update -qq \
1919
libffi-dev \
2020
libssl-dev \
2121
python3-dev \
22+
git \
2223
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*;
2324

25+
# Git needed for PROJECT_GIT_COMMIT_HASH variable setting
26+
2427
# Needs to be installed as root
2528
RUN pip3 install adafruit-nrfutil
2629
RUN pip3 install -Iv cryptography==3.3

docker/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ RUN apt-get update -qq \
1919
libssl-dev \
2020
python3-dev \
2121
python \
22+
git \
2223
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*;
2324

25+
# Git needed for PROJECT_GIT_COMMIT_HASH variable setting
26+
2427
RUN pip3 install adafruit-nrfutil
2528
RUN pip3 install -Iv cryptography==3.3
2629

src/Version.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ namespace Pinetime {
88
static constexpr uint32_t Major() {return major;}
99
static constexpr uint32_t Minor() {return minor;}
1010
static constexpr uint32_t Patch() {return patch;}
11+
static constexpr const char* GitCommitHash() {return commitHash;}
1112
static constexpr const char* VersionString() {return versionString;}
1213
private:
1314
static constexpr uint32_t major = @PROJECT_VERSION_MAJOR@;
1415
static constexpr uint32_t minor = @PROJECT_VERSION_MINOR@;
1516
static constexpr uint32_t patch = @PROJECT_VERSION_PATCH@;
17+
static constexpr const char* commitHash = "@PROJECT_GIT_COMMIT_HASH@";
1618
static constexpr const char* versionString = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@";
1719
};
1820
}

src/displayapp/screens/FirmwareValidation.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app,
2727
sprintf(version, "%ld.%ld.%ld", Version::Major(), Version::Minor(), Version::Patch());
2828
lv_label_set_text(labelVersionValue, version);
2929

30+
labelShortRefInfo = lv_label_create(lv_scr_act(), nullptr);
31+
lv_obj_align(labelShortRefInfo, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 25);
32+
lv_label_set_text(labelShortRefInfo, "ShortRef : ");
33+
lv_label_set_align(labelShortRefInfo, LV_LABEL_ALIGN_LEFT);
34+
35+
labelShortRefValue = lv_label_create(lv_scr_act(), nullptr);
36+
lv_obj_align(labelShortRefValue, labelShortRefInfo, LV_ALIGN_OUT_RIGHT_MID, 0, 0);
37+
lv_label_set_recolor(labelShortRefValue, true);
38+
sprintf(shortref, "%s", Version::GitCommitHash());
39+
lv_label_set_text(labelShortRefValue, shortref);
40+
3041
labelIsValidated = lv_label_create(lv_scr_act(), nullptr);
3142
lv_obj_align(labelIsValidated, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 50);
3243
lv_label_set_recolor(labelIsValidated, true);

src/displayapp/screens/FirmwareValidation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ namespace Pinetime {
2525

2626
lv_obj_t* labelVersionInfo;
2727
lv_obj_t* labelVersionValue;
28+
lv_obj_t* labelShortRefInfo;
29+
lv_obj_t* labelShortRefValue;
2830
char version[9];
31+
char shortref[9];
2932
lv_obj_t* labelIsValidated;
3033
lv_obj_t* buttonValidate;
3134
lv_obj_t* labelButtonValidate;

src/displayapp/screens/SystemInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ std::unique_ptr<Screen> SystemInfo::CreateScreen1() {
6969
lv_label_set_text_fmt(label,
7070
"#FFFF00 InfiniTime#\n\n"
7171
"#444444 Version# %ld.%ld.%ld\n\n"
72+
"#444444 Short Ref# %s\n\n"
7273
"#444444 Build date#\n"
7374
"%s\n"
7475
"%s\n",
7576
Version::Major(),
7677
Version::Minor(),
7778
Version::Patch(),
79+
Version::GitCommitHash(),
7880
__DATE__,
7981
__TIME__);
8082
lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);

0 commit comments

Comments
 (0)