Skip to content

Commit 74aef00

Browse files
author
Bytekeeper
committed
Added hash commit number as info and fixed alignments of duration value texts.
1 parent 7513e19 commit 74aef00

File tree

8 files changed

+55
-10
lines changed

8 files changed

+55
-10
lines changed

build.gradle

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ jar {
8080
processResources {
8181
filesMatching('version.info') {
8282
filter(ReplaceTokens, tokens: [
83-
"app.version": project.property("version")
83+
"app.version": project.property("version"),
84+
"app.hash": getCheckedOutGitCommitHash()
8485
])
8586
}
8687
}
@@ -111,4 +112,22 @@ gradle.taskGraph.whenReady {taskGraph ->
111112
generateGrammarSource {
112113
maxHeapSize = "64m"
113114
arguments += ["-visitor", "-long-messages"]
115+
}
116+
117+
def getCheckedOutGitCommitHash() {
118+
def gitFolder = "$projectDir/.git/"
119+
def takeFromHash = 12
120+
/*
121+
* '.git/HEAD' contains either
122+
* in case of detached head: the currently checked out commit hash
123+
* otherwise: a reference to a file containing the current commit hash
124+
*/
125+
def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD
126+
def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd
127+
// def isRef = head.length > 1 // ref: refs/heads/master
128+
129+
if(isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb
130+
131+
def refHead = new File(gitFolder + head[1].trim()) // .git/refs/heads/master
132+
refHead.text.trim().take takeFromHash
114133
}

src/main/java/org/stt/BaseModule.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,10 @@ static URL provideReleaseURL(@Named("applicationMetadata") Properties applicatio
122122
throw new UncheckedIOException(e);
123123
}
124124
}
125+
126+
@Provides
127+
@Named("commit hash")
128+
static String provideCommitHash(@Named("applicationMetadata") Properties applicationMetadata) {
129+
return applicationMetadata.getProperty("app.hash");
130+
}
125131
}

src/main/java/org/stt/gui/jfx/InfoController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,26 @@ public class InfoController {
3737
@FXML
3838
private Label versionLabel;
3939
@FXML
40+
private Label hashValue;
41+
@FXML
4042
private VBox updateArea;
4143
private Font fontAwesome;
4244
private final String appVersion;
45+
private String commitHash;
4346
private final ExecutorService executorService;
4447

4548
@Inject
4649
public InfoController(ResourceBundle localization,
4750
UpdateChecker updateChecker,
4851
@Named("glyph") Font fontAwesome,
4952
@Named("version") String appVersion,
53+
@Named("commit hash") String commitHash,
5054
ExecutorService executorService) {
5155
this.localization = requireNonNull(localization);
5256
this.updateChecker = requireNonNull(updateChecker);
5357
this.fontAwesome = requireNonNull(fontAwesome);
5458
this.appVersion = requireNonNull(appVersion);
59+
this.commitHash = requireNonNull(commitHash);
5560
this.executorService = requireNonNull(executorService);
5661
FXMLLoader loader = new FXMLLoader(getClass().getResource(
5762
"/org/stt/gui/jfx/InfoPanel.fxml"), localization);
@@ -66,6 +71,7 @@ public InfoController(ResourceBundle localization,
6671
@FXML
6772
public void initialize() {
6873
versionLabel.setText(appVersion);
74+
hashValue.setText(commitHash);
6975
}
7076

7177
public Pane getPanel() {

src/main/java/org/stt/gui/jfx/ReportController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ public void initialize() {
176176
.bind(STTBindings
177177
.formattedDuration(createBindingForRoundedDurationSum(reportListModel)));
178178

179+
columnForRoundedDuration.setStyle("-fx-alignment: CENTER-RIGHT;");
180+
columnForDuration.setStyle("-fx-alignment: CENTER-RIGHT;");
181+
179182
setRoundedDurationColumnCellFactoryToConvertDurationToString();
180183
setDurationColumnCellFactoryToConvertDurationToString();
181184
setCommentColumnCellFactory();

src/main/resources/org/stt/gui/Application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ info.updateButton=Check for update
1212
info.upToDate=This is the most recent version
1313
info.newerVersion=Version %s of is available!
1414
info.nameAndVersion=SimpleTimeTracking Version:
15+
info.hash=Commit Hash:
1516

1617
window.title=SimpleTimeTracking
1718
show_report=Show _report

src/main/resources/org/stt/gui/jfx/InfoPanel.fxml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<?import javafx.geometry.Insets?>
4-
<?import javafx.scene.control.Button?>
5-
<?import javafx.scene.control.Hyperlink?>
6-
<?import javafx.scene.control.Label?>
4+
<?import javafx.scene.control.*?>
75
<?import javafx.scene.image.Image?>
86
<?import javafx.scene.image.ImageView?>
97
<?import javafx.scene.layout.*?>
@@ -18,23 +16,34 @@
1816
</VBox>
1917
</bottom>
2018
<center>
21-
<VBox alignment="CENTER" BorderPane.alignment="CENTER">
19+
<VBox alignment="CENTER" fillWidth="false" BorderPane.alignment="CENTER">
2220
<children>
2321
<ImageView fitHeight="150.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true">
2422
<image>
2523
<Image url="@../../../../Logo.png"/>
2624
</image>
2725
</ImageView>
28-
<FlowPane alignment="TOP_CENTER" hgap="5.0">
26+
<GridPane>
27+
<columnConstraints>
28+
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0" prefWidth="250.0"/>
29+
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="150.0"/>
30+
</columnConstraints>
31+
<rowConstraints>
32+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
33+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
34+
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
35+
</rowConstraints>
2936
<children>
3037
<Label text="%info.nameAndVersion">
3138
<padding>
3239
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
3340
</padding>
3441
</Label>
35-
<Label fx:id="versionLabel" text="Unknown"/>
42+
<Label fx:id="versionLabel" GridPane.columnIndex="1"/>
43+
<Label text="%info.hash" GridPane.rowIndex="1"/>
44+
<Label fx:id="hashValue" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
3645
</children>
37-
</FlowPane>
46+
</GridPane>
3847
</children>
3948
</VBox>
4049
</center>

src/main/resources/org/stt/gui/jfx/ReportPanel.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<GridPane hgap="10.0">
2626
<columnConstraints>
2727
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0"/>
28-
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
28+
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
2929
</columnConstraints>
3030
<rowConstraints>
3131
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>
@@ -50,7 +50,7 @@
5050
<GridPane hgap="10.0">
5151
<columnConstraints>
5252
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0"/>
53-
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
53+
<ColumnConstraints halignment="RIGHT" hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0"/>
5454
</columnConstraints>
5555
<rowConstraints>
5656
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES"/>

src/main/resources/version.info

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
app.version=@app.version@
2+
app.hash=@app.hash@
23
release.url=https://api.github.com/repos/SimpleTimeTracking/StandaloneClient/releases

0 commit comments

Comments
 (0)