Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix error where an intermediate None value was breaking jinja2 for git #1088

Merged
merged 1 commit into from
Jul 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else 0 should be None here, so that build_number triggers jinja invalid messages.


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