This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 7c345e9 Small improvement on GitBranchHash which is able to get at
least the hash of a detached HEAD
7c345e9 is described below
commit 7c345e94105289f290b0c6d96f33cdd1b99d477b
Author: Laszlo Kishalmi <[email protected]>
AuthorDate: Thu Nov 25 13:48:48 2021 -0800
Small improvement on GitBranchHash which is able to get at least the hash
of a detached HEAD
---
.../antsrc/org/netbeans/nbbuild/GitBranchHash.java | 33 ++++++++++++++--------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/GitBranchHash.java
b/nbbuild/antsrc/org/netbeans/nbbuild/GitBranchHash.java
index 2d53fe8..2418f4b 100644
--- a/nbbuild/antsrc/org/netbeans/nbbuild/GitBranchHash.java
+++ b/nbbuild/antsrc/org/netbeans/nbbuild/GitBranchHash.java
@@ -79,19 +79,25 @@ public class GitBranchHash extends Task {
if (headroot != null && Files.size(headroot) > 0l) {
List<String> lines = Files.readAllLines(headroot);
String line = lines.get(0);
- String revLink = line.substring(line.indexOf(':')+1).trim();
- branch = revLink.substring(revLink.lastIndexOf('/')+1).trim();
- Path revPath = headroot.getParent().resolve(revLink);
- if(Files.isRegularFile(revPath) && Files.size(revPath) > 0l) {
- List<String> revlines = Files.readAllLines(revPath);
- String revline = revlines.get(0);
- if(revline.length()>=12){
- hash = revline.trim();
+ if (!line.contains(":") && (line.length() == 40)) {
+ //Detached HEAD
+ hash = line;
+ log("Detached HEAD please specify '" + branchProperty + "'
externally.", Project.MSG_WARN);
+ } else {
+ String revLink =
line.substring(line.indexOf(':')+1).trim();
+ branch =
revLink.substring(revLink.lastIndexOf('/')+1).trim();
+ Path revPath = headroot.getParent().resolve(revLink);
+ if(Files.isRegularFile(revPath) && Files.size(revPath) >
0l) {
+ List<String> revlines = Files.readAllLines(revPath);
+ String revline = revlines.get(0);
+ if(revline.length()>=12){
+ hash = revline.trim();
+ } else {
+ log("no content in " + revPath, Project.MSG_WARN);
+ }
} else {
- log("no content in " + revPath, Project.MSG_WARN);
+ log("unable to find revision info for " + revPath,
Project.MSG_WARN);
}
- } else {
- log("unable to find revision info for " + revPath,
Project.MSG_WARN);
}
} else {
log("No HEAD found starting from " + file, Project.MSG_WARN);
@@ -99,11 +105,14 @@ public class GitBranchHash extends Task {
} catch(IOException ex) {
log("Could not read " + headroot + ": " + ex, Project.MSG_WARN);
}
- if (!branch.isEmpty() && !hash.isEmpty()) {
+ if (!branch.isEmpty()) {
getProject().setNewProperty(branchProperty, branch);
+ }
+ if (!hash.isEmpty()) {
getProject().setNewProperty(hashProperty, hash);
}
}
}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists