I've begun versioning my commits with git tag -a v2.3.4 -m 'some message' so that I can label my software releases with version numbers (e.g. 2.3.4)
I'd like to have an "about" menu item in the software where a user could display what version they are running.
Is there a way to do this (preferably in Java) so that my app can "know" its version tag in git???
If you have your repo local:
import java.io.*;
public class HelloWorld
{
public static void main(String []args) throws IOException
{
System.out.println("Hello World");
String command = "git describe --abbrev=0 --tags";
Process p = Runtime.getRuntime().exec(command);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
String text = command + "\n";
System.out.println(text);
while ((line = input.readLine()) != null)
{
text += line;
System.out.println("Line: " + line);
}
}
}
Maybe check with https://www.tutorialspoint.com/compile_java8_online.php
If you have your repo on Github:
https://api.github.com/repos/YOURNAME/YOURREPO/tags
For example:
https://api.github.com/repos/git/git/tags
This will get you the newest 30 Git repo tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With