Last active
September 2, 2020 06:33
-
-
Save hikerpig/fdf842afea5dbaf2e2f0d322a67c3bf9 to your computer and use it in GitHub Desktop.
UltiSnips snippet for gerrit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global !p | |
#! /usr/bin/env python | |
import hashlib | |
def make_change_id(): | |
fd = open("/dev/urandom", "rb") | |
buf = fd.read(80) | |
hash = hashlib.sha1() | |
hash.update(buf) | |
change_id = hash.hexdigest() | |
return "Change-Id: I" + change_id | |
endglobal | |
snippet changeid "Generate Change-Id line" | |
`!p if not snip.c: snip.rv = make_change_id()` | |
endsnippet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment