This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS: Getting git SHA-1 into CCS compiled application

Tool/software: Code Composer Studio

Hi, 

I have seen the answer for getting the SHA-1 through a script file.

but is  any other way to add the git Head into the build env variable, all other info from git has got the env variable (git_branch, git_tree, git_dir)

except for the commit head info.

Has anyone tried, changing the env variable, to include the git head, or ECLIPSE DYNAMIC VARIABLE to add the variable from the eclipse plugin

please let me know.

Kind regards,

Nancy

  • Nancy,

    It likely would be feasible to write an Eclipse plug-in that read in the information and populated a new ECLIPSE DYNAMIC VARIABLE or even just a regular editable variable.

    I have not been able to find anything in the EGit documentation on getting the SHA-1 into a variable.

    The script was the only way I could figure out to do this in the past. Today I tried using %GIT_COMMIT% and then putting that into a --define predefined symbol and converting that to a string. However for me the environment variable %GIT_COMMIT% is not defined. So I just end up with %GIT_COMMIT% in my string. Maybe I need to run a Git command as a pre-build step to ensure that is populated? I am a very casual Git user so I am not sure when that variable has a value.

    Regards,
    John
  • Nancy,

    Is the environment variable GIT_COMMIT defined in your system.  Others have mentioned that this contains the SHA after a commit.  If this is defined on your system I believe I have a solution.

    GIT_COMMIT is not defined on my system so I created a variable TEST_ENV_VAR

    I did this in Windows control panel:

    Then I added the following to my build options.  Basically I added a predefined symbol SHA and set it equal to TEST_ENV_VAR. 

    SHA=${TEST_ENV_VAR}

    Then in my test application I added the following to test it out:

    This worked:

    Regards,

    John

  • Just to be sure, I dont have git_commit, defined in my system;
    The other thing is we use master, as well branch at times, so i'm not sure how it would work in that scenario, if i define the git_coommit in window.
    The suggestions sounds good, i will use if i want to include any pre build in future, but i dont think it would do what i want it to do just now.

    I'm looking for something similar to git_branch that already exists in the CCS, which is predefined env var, that fetches the latest info of the CCS project that is being built.
  • Nancy,

    I am not sure what else I can do.

    Those git variables are coming straight from the Eclipse git integration (EGit).  You can see the full list of variables available here:

    If what you need is available in an OS environment variable you can use the method I described.

    If there is a git command to provide what you need you can use the script method mentioned on the other thread.

    Other than that I can't see what else to do here.

    Regards,

    John

  • Thanks for your response, as in the question tagged, looks like script is the only way.