postreceive: fix the problem that getEnvVar may panic
The input passed to the getEnvVar() is not controllable. For example, when the input env string is "foo" and the value of key is also "foo", then getEnvVar() will cause panic exception because the parsed array is out of range.
When the array length of the parsed env string is less than 2 then it is skipped directly because incorrect KV format should be considered invaild. Also added unit test for getEnvVar().
Changelog: fixed
Signed-off-by: Chen Bojun bojun.cbj@gmail.com