Skip to content

Commit bd14e77

Browse files
committed
Merge branch 'version-handling'
2 parents 32335ba + abce89e commit bd14e77

File tree

21 files changed

+274
-98
lines changed

21 files changed

+274
-98
lines changed

BuiltInChips/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.nand2tetris</groupId>
77
<artifactId>parent</artifactId>
8-
<version>2.5-SNAPSHOT</version>
8+
<version>2.6-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>BuiltInChips</artifactId>

BuiltInVMCode/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.nand2tetris</groupId>
77
<artifactId>parent</artifactId>
8-
<version>2.5-SNAPSHOT</version>
8+
<version>2.6-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>BuiltInVMCode</artifactId>

CPUEmulator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.nand2tetris</groupId>
77
<artifactId>parent</artifactId>
8-
<version>2.5-SNAPSHOT</version>
8+
<version>2.6-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>CPUEmulator</artifactId>

CompilersPackage/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.nand2tetris</groupId>
77
<artifactId>parent</artifactId>
8-
<version>2.5-SNAPSHOT</version>
8+
<version>2.6-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>CompilersPackage</artifactId>

HackGUIPackage/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.nand2tetris</groupId>
77
<artifactId>parent</artifactId>
8-
<version>2.5-SNAPSHOT</version>
8+
<version>2.6-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>HackGUIPackage</artifactId>

HackPackage/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.nand2tetris</groupId>
77
<artifactId>parent</artifactId>
8-
<version>2.5-SNAPSHOT</version>
8+
<version>2.6-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>HackPackage</artifactId>

HackPackage/src/main/java/Hack/Utilities/Definitions.java

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
/********************************************************************************
2-
* The contents of this file are subject to the GNU General Public License *
3-
* (GPL) Version 2 or later (the "License"); you may not use this file except *
4-
* in compliance with the License. You may obtain a copy of the License at *
5-
* http://www.gnu.org/copyleft/gpl.html *
6-
* *
7-
* Software distributed under the License is distributed on an "AS IS" basis, *
8-
* without warranty of any kind, either expressed or implied. See the License *
9-
* for the specific language governing rights and limitations under the *
10-
* License. *
11-
* *
12-
* This file was originally developed as part of the software suite that *
13-
* supports the book "The Elements of Computing Systems" by Nisan and Schocken, *
14-
* MIT Press 2005. If you modify the contents of this file, please document and *
15-
* mark your changes clearly, for the benefit of others. *
16-
********************************************************************************/
1+
/*
2+
* The contents of this file are subject to the GNU General Public License
3+
* (GPL) Version 2 or later (the "License"); you may not use this file except
4+
* in compliance with the License. You may obtain a copy of the License at
5+
* http://www.gnu.org/copyleft/gpl.html
6+
*
7+
* Software distributed under the License is distributed on an "AS IS" basis,
8+
* without warranty of any kind, either expressed or implied. See the License
9+
* for the specific language governing rights and limitations under the
10+
* License.
11+
*
12+
* This file was originally developed as part of the software suite that
13+
* supports the book "The Elements of Computing Systems" by Nisan and Schocken,
14+
* MIT Press 2005. If you modify the contents of this file, please document and
15+
* mark your changes clearly, for the benefit of others.
16+
*/
1717

1818
package Hack.Utilities;
1919

20+
import java.io.IOException;
2021
import java.util.*;
2122
import java.awt.event.*;
2223

@@ -28,7 +29,7 @@ public class Definitions {
2829
/**
2930
* Current software version
3031
*/
31-
public static final String version = "2.5";
32+
public static final String version = buildVersion();
3233

3334
/**
3435
* Size of RAM
@@ -543,4 +544,13 @@ private void initKeyCodes() {
543544
actionKeyCodes[KeyEvent.VK_F12] = F12_KEY;
544545
actionKeyCodes[KeyEvent.VK_INSERT] = INSERT_KEY;
545546
}
547+
548+
private static String buildVersion() {
549+
try {
550+
final GitRepositoryState git = GitRepositoryState.getGitRepositoryState();
551+
return String.format("%s - %s", git.getBuildVersion(), git.getDescribeShort());
552+
} catch (IOException e) {
553+
return "unknown";
554+
}
555+
}
546556
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
package Hack.Utilities;
2+
3+
import java.io.IOException;
4+
import java.util.Properties;
5+
6+
public class GitRepositoryState {
7+
private static GitRepositoryState gitRepositoryState;
8+
private final String tags;
9+
private final String branch;
10+
private final String dirty;
11+
private final String remoteOriginUrl;
12+
private final String commitId;
13+
private final String commitIdAbbrev;
14+
private final String describe;
15+
private final String describeShort;
16+
private final String commitUserName;
17+
private final String commitUserEmail;
18+
private final String commitMessageFull;
19+
private final String commitMessageShort;
20+
private final String commitTime;
21+
private final String closestTagName;
22+
private final String closestTagCommitCount;
23+
private final String buildUserName;
24+
private final String buildUserEmail;
25+
private final String buildTime;
26+
private final String buildHost;
27+
private final String buildVersion;
28+
29+
public static GitRepositoryState getGitRepositoryState() throws IOException {
30+
if (gitRepositoryState == null) {
31+
Properties properties = new Properties();
32+
properties.load(GitRepositoryState.class.getClassLoader().getResourceAsStream("git.properties"));
33+
34+
gitRepositoryState = new GitRepositoryState(properties);
35+
}
36+
return gitRepositoryState;
37+
}
38+
39+
private GitRepositoryState(Properties properties) {
40+
this.tags = String.valueOf(properties.get("git.tags"));
41+
this.branch = String.valueOf(properties.get("git.branch"));
42+
this.dirty = String.valueOf(properties.get("git.dirty"));
43+
this.remoteOriginUrl = String.valueOf(properties.get("git.remote.origin.url"));
44+
45+
this.commitId = String.valueOf(properties.get("git.commit.id.full")); // OR properties.get("git.commit.id") depending on your configuration
46+
this.commitIdAbbrev = String.valueOf(properties.get("git.commit.id.abbrev"));
47+
this.describe = String.valueOf(properties.get("git.commit.id.describe"));
48+
this.describeShort = String.valueOf(properties.get("git.commit.id.describe-short"));
49+
this.commitUserName = String.valueOf(properties.get("git.commit.user.name"));
50+
this.commitUserEmail = String.valueOf(properties.get("git.commit.user.email"));
51+
this.commitMessageFull = String.valueOf(properties.get("git.commit.message.full"));
52+
this.commitMessageShort = String.valueOf(properties.get("git.commit.message.short"));
53+
this.commitTime = String.valueOf(properties.get("git.commit.time"));
54+
this.closestTagName = String.valueOf(properties.get("git.closest.tag.name"));
55+
this.closestTagCommitCount = String.valueOf(properties.get("git.closest.tag.commit.count"));
56+
57+
this.buildUserName = String.valueOf(properties.get("git.build.user.name"));
58+
this.buildUserEmail = String.valueOf(properties.get("git.build.user.email"));
59+
this.buildTime = String.valueOf(properties.get("git.build.time"));
60+
this.buildHost = String.valueOf(properties.get("git.build.host"));
61+
this.buildVersion = String.valueOf(properties.get("git.build.version"));
62+
}
63+
64+
public String getTags() {
65+
return tags;
66+
}
67+
68+
public String getBranch() {
69+
return branch;
70+
}
71+
72+
public String getDirty() {
73+
return dirty;
74+
}
75+
76+
public String getRemoteOriginUrl() {
77+
return remoteOriginUrl;
78+
}
79+
80+
public String getCommitId() {
81+
return commitId;
82+
}
83+
84+
public String getCommitIdAbbrev() {
85+
return commitIdAbbrev;
86+
}
87+
88+
public String getDescribe() {
89+
return describe;
90+
}
91+
92+
public String getDescribeShort() {
93+
return describeShort;
94+
}
95+
96+
public String getCommitUserName() {
97+
return commitUserName;
98+
}
99+
100+
public String getCommitUserEmail() {
101+
return commitUserEmail;
102+
}
103+
104+
public String getCommitMessageFull() {
105+
return commitMessageFull;
106+
}
107+
108+
public String getCommitMessageShort() {
109+
return commitMessageShort;
110+
}
111+
112+
public String getCommitTime() {
113+
return commitTime;
114+
}
115+
116+
public String getClosestTagName() {
117+
return closestTagName;
118+
}
119+
120+
public String getClosestTagCommitCount() {
121+
return closestTagCommitCount;
122+
}
123+
124+
public String getBuildUserName() {
125+
return buildUserName;
126+
}
127+
128+
public String getBuildUserEmail() {
129+
return buildUserEmail;
130+
}
131+
132+
public String getBuildTime() {
133+
return buildTime;
134+
}
135+
136+
public String getBuildHost() {
137+
return buildHost;
138+
}
139+
140+
public String getBuildVersion() {
141+
return buildVersion;
142+
}
143+
}

HardwareSimulator/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.nand2tetris</groupId>
77
<artifactId>parent</artifactId>
8-
<version>2.5-SNAPSHOT</version>
8+
<version>2.6-SNAPSHOT</version>
99
</parent>
1010

1111
<artifactId>HardwareSimulator</artifactId>

InstallDir/CPUEmulator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22
cd `dirname $0`
3-
java -jar ../CPUEmulator/target/CPUEmulator-2.5-SNAPSHOT.jar $1
3+
java -jar ../CPUEmulator/target/CPUEmulator-2.6-SNAPSHOT.jar $1

0 commit comments

Comments
 (0)