2

So I am using a PHP script to create a webhook with Gitlab. However, I am running into a slight issue. Finding the short commit ID. How would I find this? I can't seem to find it within PHP. Thanks!

The solutions I've seen are using the PHP exec() function which I definitely do not want enabled on my web server.

I expect the commit ID in the webhook to appear as something such as "2e54ar" rather than having the long string of numbers and letters.

1 Answers1

0

By default, a (GitLab or GitHub) webhook would always send a JSON payload including full SHA1 references in it, to avoid any confusion.

If you want short SHA1 (without executing any command), you could simply use substr

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Would this commit ID still be valid? (i.e. searchable, etc.) – Blizzard098 Mar 26 '19 at 17:14
  • @Blizzard098 Most often, yes. If not, you can disambiguate it: https://stackoverflow.com/a/39930978/6309. see also https://stackoverflow.com/a/21015031/6309. – VonC Mar 26 '19 at 17:19