Handle repos with no tags in version-from-git

The version-from-git role doesn't properly handle tag-less repos. Update
it to handle that case too.

Change-Id: I358037fd34f5dc202a6761b9e6f81bbe7870f3f2
This commit is contained in:
Monty Taylor 2018-03-06 11:25:05 -06:00 committed by Tobias Henkel
parent fd35b1b9aa
commit a966445c16
1 changed files with 21 additions and 0 deletions

View File

@ -54,9 +54,30 @@
- skip_ansible_lint
- name: Set commits_since_tag fact
when: commits_since_tag_output.rc == 0
set_fact:
commits_since_tag: "{{ commits_since_tag_output.stdout }}"
# Some repos, like storyboard-webclient, do not have any tags. git describe
# throws an error in those repos. To be consistent, do a commit count the
# hard way.
- block:
when: not commits_since_tag_output.rc != 0
- name: Get commits since the beginning
command: git rev-list HEAD --count
register: commits_since_beginning
args:
chdir: "{{ zuul_work_dir }}"
# ANSIBLE0006: Skip linting since it triggers on the "git" command,
# but rev-list is not supported by ansible git module.
tags:
- skip_ansible_lint
- name: Set commits_since_tag fact
set_fact:
commits_since_tag: "{{ commits_since_beginning.stdout }}"
- name: Set project_ver to scm_tag if there are no commits
when: not commits_since_tag
set_fact: