Skip to content

Commit

Permalink
fix error where an intermediate None value was breaking jinja2 for git
Browse files Browse the repository at this point in the history
  • Loading branch information
msarahan committed Jul 3, 2016
1 parent d672e07 commit d7fcafc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion conda_build/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ def version(self):
return res

def build_number(self):
return int(self.get_value('build/number', 0))
number = self.get_value('build/number', 0)
# build number can come back as None if no setting (or jinja intermediate)
return int(number) if number else 0

def ms_depends(self, typ='run'):
res = []
Expand Down
11 changes: 11 additions & 0 deletions tests/test-recipes/metadata/_git_describe_number_branch/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package:
name: git_describe_number_branch
version: {{ GIT_DESCRIBE_TAG }}

source:
git_url: https://github.com/conda/conda_build_test_recipe
git_branch: 1.20.2+1

build:
number: {{ GIT_DESCRIBE_NUMBER }}
string: {{ GIT_BUILD_STR }}
12 changes: 12 additions & 0 deletions tests/test_build_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,15 @@ def test_patch():
lines = modified.readlines()
assert lines[0] == '43770\n'
os.chdir(basedir)


def test_git_describe_info_on_branch():
cmd = 'conda build --output {}'.format(os.path.join(metadata_dir, "_git_describe_number_branch"))
process = subprocess.Popen(cmd.split(),
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()
test_path = os.path.join(sys.prefix, "conda-bld", subdir,
"git_describe_number_branch-1.20.2-1_g82c6ba6.tar.bz2")
output = output.decode('utf-8').rstrip()
error = error.decode('utf-8')
assert test_path == output, error

0 comments on commit d7fcafc

Please sign in to comment.