Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudy-Orozco committed Apr 27, 2024
2 parents 50dfb02 + 58a8558 commit 9022c4e
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/java/uta/cse3310/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -88,7 +89,7 @@ public class App extends WebSocketServer {

private ChatHandler chatHandler;

private String version = null;
private static String hash = null;

private int pnum = 0;

Expand All @@ -114,6 +115,23 @@ public App(int port, Draft_6455 draft) {
super(new InetSocketAddress(port), Collections.<Draft>singletonList(draft));
}

public static void currHash(){ // Enviorment variable version always null, adding this back in to change it to the current hash
String sResults = null;
try{
Process process = Runtime.getRuntime().exec("git rev-parse HEAD"); // Starts a process to get the hash

InputStream results = process.getInputStream(); // Capture results of command

BufferedReader reader = new BufferedReader(new InputStreamReader(results));
StringBuilder output = new StringBuilder();
while((sResults = reader.readLine()) != null) {
output.append(sResults).append("\n");
}
hash = output.toString().trim();
}
catch(IOException e){}
}

@Override
public void onOpen(WebSocket conn, ClientHandshake handshake) {
connectionId++;
Expand Down Expand Up @@ -442,8 +460,7 @@ public static void main(String[] args) {
A.start();
System.out.println("websocket Server started on port: " + port);

A.version = System.getenv("VERSION");
System.out.println("Current github hash : " + A.version); // Will work once it is connected to the web site

currHash();// System.getenv("VERSION"); alwways gives null
System.out.println("Current github hash : " + A.hash);
}
}

0 comments on commit 9022c4e

Please sign in to comment.