In the NuBot standard output and in the logs, record both the version and sub-version, if it exists

Issue #176 resolved
Ben Rossi created an issue

Right now one of the first lines in a session's logs is the version of NuBot being run. This is useful information for troubleshooting:

INFO: Setting up  NuBot version : 0.1.5

Unfortunately, if we're testing multiple RC's over time, it's not possible to review the logs with the context of which RC is being displayed. Can NuBot be made aware of its sub-version or git tag? Even the commit SHA of the last commit included would be useful if that was the easiest to include.

INFO: Setting up  NuBot version : 0.1.5 (tag: 0.1.5-RC6)
INFO: Setting up  NuBot version : 0.1.5 (641afb3)

Comments (9)

  1. Desrever Nu

    moved it to 0.2.1 . Doing this will also force some good practices in the codebase. Those changes will also make possible to get some automatic build with proper naming. so definitely worth it

  2. Benjamin Cordes

    Ok, the way this works now is that in the distribution the version number is stored + the last commit. The distribution contains a ".nubot" file.

    This gradle task produces the .nubot file. If run as jar, NuBot knows we're in a jar and can find the file. Otherwise version is develop.

    task propfile << {
        def prop = new Properties()
        prop.put("version",project.version)
    
        //determine hash of current branch
        def proc = "git rev-parse HEAD".execute()
        def b = new StringBuffer()
        proc.consumeProcessErrorStream(b)
        def h = proc.text
        h = h.replace("\n","")
        prop.put("lastcommit",h);
    
        def propFile = new File("${distdir}/.nubot")
        propFile.createNewFile();
        prop.store(propFile.newWriter(), null);
    
        println 'this project is version ' + project.version
    }
    
  3. Log in to comment