Get github id from git log, locally or in travis?

hmmm… I think I may have painted myself into a corner a bit. My students run a set of unit tests on their repos before handing them in. I then run the same unit tests in travis-ci, and if they don’t pass, I send them a note saying that they need to resubmit.

One set of tests is related to their git config info and git commit history. I check that they have a minimum number of commits, and sometimes the files they hand in need to be named according to their github ID’s, which they are required to configure with git config --set github.user.

So, in these cases the tests read from local git config file. Unfortunately, that config of course doesn’t exist on travis (nor on my local computer, of course). Those tests therefore fail in those environments.

Is there any way for travis, at least, to extract the github id from git commit history? or for me to get it from the GH repo over the github API? Also has anyone else run into this issue, and what did you come up with?

Thank you!

By using GitHub API you can easily retrieve all the information you need.

1 Like

When you’re running on Travis, it’s just a Linux VM with all the usual commands, so you could have your test script or Gradle action depend on a call out to run git commands or whatever else. The trick is that you want to look into the environment beyond the Git repo. That environment is obviously going to be different from the students’ computers to Travis-CI’s cloud server.

One way you could infer the GitHub account name is as a suffix of the repository name. This will work great for solo projects, but it won’t work for group projects where the team’s name is the suffix.