doStepIf = IsMakeCleanRequested(tuple[0])
))
+ # Workaround bug when switching from a checked out tag back to a branch
+ # Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-June/017809.html
+ factory.addStep(ShellCommand(
+ name = "gitcheckout",
+ description = "Ensure that Git HEAD is sane",
+ command = "if [ -d .git ]; then git checkout master; else exit 0; fi",
+ haltOnFailure = True))
+
# check out the source
# Git() runs:
# if repo doesn't exist: 'git clone repourl'
doStepIf = IsTaggingRequested
))
+ # Verify that Git HEAD points to a tag or branch
+ # Ref: http://lists.infradead.org/pipermail/openwrt-devel/2019-June/017809.html
+ factory.addStep(ShellCommand(
+ name = "gitverify",
+ description = "Ensure that Git HEAD is pointing to a branch or tag",
+ command = 'git rev-parse --abbrev-ref HEAD | grep -vxqF HEAD || git show-ref --tags --dereference 2>/dev/null | sed -ne "/^$(git rev-parse HEAD) / { s|^.*/||; s|\\^.*||; p }" | grep -qE "^v[0-9][0-9]\\."',
+ haltOnFailure = True))
+
factory.addStep(ShellCommand(
name = "rmtmp",
description = "Remove tmp folder",