Repository: conda/conda-build

Issue:
GIT_FULL_HASH is undefined error on conda build
I am getting a "GIT_FULL_HASH is undefined" error when running conda build . I can get the hash manually by issuing the command - "git rev-parse HEAD"
Is there anything specific I should configure to set these variables? 

package:
    name: myFirstModule
    # String with the full SHA1 of the current HEAD
    version: {{ GIT_FULL_HASH }}





Discussion:
Do you have a source section in your recipe?  Conda-build only supports GIT_* variables if you have

```
source:
  git_url: (https url of repo, or relative path to repo on local filesystem.  relative to where meta.yaml lives)
```

or

```
source:
  path: (some relative filesystem path - relative to where meta.yaml for recipe is)
```
Yes, the source path is set to parent directory.
source:
  path: ..

My directory structure is as below - 
MyPacakge
   -setup.py
   -myFirstModule
   -condarecipe
             ---meta.yaml
            ---build.sh
 
 build command - "conda build condarecipe"             


That all seems in order.  Can you push this git repo somewhere?  I'll be happy to clone it and try to debug it.
Hi,  I have pushed the repo here :  https://github.com/betranjacob/conda_build_test
Please have a look. 

Resolving patch:
diff --git a/conda_build/environ.py b/conda_build/environ.py
--- a/conda_build/environ.py
+++ b/conda_build/environ.py
@@ -157,14 +157,16 @@ def get_git_info(repo, config):
 
     try:
         output = utils.check_output_env(["git", "describe", "--tags", "--long", "HEAD"],
-                                         env=env, cwd=os.path.dirname(repo),
-                                         stderr=stderr).splitlines()[0]
+                                        env=env, cwd=os.path.dirname(repo),
+                                        stderr=stderr).splitlines()[0]
         output = output.decode('utf-8')
-
         parts = output.rsplit('-', 2)
         if len(parts) == 3:
             d.update(dict(zip(keys, parts)))
+    except subprocess.CalledProcessError:
+        log.warn("Failed to obtain git tag information.  Are you using annotated tags?")
 
+    try:
         # get the _full_ hash of the current HEAD
         output = utils.check_output_env(["git", "rev-parse", "HEAD"],
                                          env=env, cwd=os.path.dirname(repo),
@@ -172,17 +174,17 @@ def get_git_info(repo, config):
         output = output.decode('utf-8')
 
         d['GIT_FULL_HASH'] = output
-        # set up the build string
-        if "GIT_DESCRIBE_NUMBER" in d and "GIT_DESCRIBE_HASH" in d:
-            d['GIT_BUILD_STR'] = '{}_{}'.format(d["GIT_DESCRIBE_NUMBER"],
-                                                d["GIT_DESCRIBE_HASH"])
-
-        # issues on Windows with the next line of the command prompt being recorded here.
-        assert not any("\n" in value for value in d.values())
-
     except subprocess.CalledProcessError as error:
-        log.warn("Error obtaining git information in get_git_info.  Error was: ")
+        log.warn("Error obtaining git commit information.  Error was: ")
         log.warn(str(error))
+
+    # set up the build string
+    if "GIT_DESCRIBE_NUMBER" in d and "GIT_DESCRIBE_HASH" in d:
+        d['GIT_BUILD_STR'] = '{}_{}'.format(d["GIT_DESCRIBE_NUMBER"],
+                                            d["GIT_DESCRIBE_HASH"])
+
+    # issues on Windows with the next line of the command prompt being recorded here.
+    assert not any("\n" in value for value in d.values())
     return d
 
 


Test patch: