fix branch handling and auto-detection

This commit is contained in:
riscy 2020-05-16 20:39:16 -07:00
parent 905be79b73
commit b09e783416
2 changed files with 20 additions and 14 deletions

View file

@ -21,15 +21,21 @@ jobs:
pip install . mypy pytest black
- name: Test
run: make test-melpazoid
- name: Test 'shx' Pull Request # a small package with few dependencies
env: # ... which already exists on MELPA:
EXIST_OK: true
env:
CI_BRANCH: master # always build the master branch for this repo
EXIST_OK: true # we expect that it already exists on MELPA
run: MELPA_PR_URL=https://github.com/melpa/melpa/pull/4749 make
- name: Test 'kanban' Recipe # notably this is a Mercurial recipe
env: # ...and we expect it to have some nags:
EXPECT_ERROR: 2
env:
CI_BRANCH: default # always build the default branch on this repo
EXPECT_ERROR: 2 # we expect it to have some nags
run: RECIPE='(kanban :fetcher hg :url "https://hg.sr.ht/~arnebab/kanban.el")' make
- name: Test 'magit' Recipe # magit is a large recipe
env: # ...which may have a couple of nags:
EXPECT_ERROR: 2
env:
CI_BRANCH: master # always build the master branch on this repo
EXPECT_ERROR: 2 # we expect it to have some nags
run: RECIPE='(magit :fetcher github :repo "magit/magit" :files ("lisp/magit" "lisp/magit*.el" "lisp/git-rebase.el" "Documentation/magit.texi" "Documentation/AUTHORS.md" "LICENSE" (:exclude "lisp/magit-libgit.el")))' make

View file

@ -613,14 +613,14 @@ def _clone(repo: str, into: str, branch: str, fetcher: str = 'github') -> bool:
# check if we're being used in GitHub CI -- if so, modify the branch
if not branch and 'RECIPE' in os.environ:
os.path.split(os.environ.get('GITHUB_REF', ''))
branch = os.path.split(os.environ.get('GITHUB_REF', ''))[-1]
if not branch:
branch = os.environ.get('TRAVIS_PULL_REQUEST_BRANCH', '')
if not branch:
branch = os.environ.get('TRAVIS_BRANCH', '')
branch = (
os.environ.get('CI_BRANCH', '')
or os.path.split(os.environ.get('GITHUB_REF', ''))[-1]
or os.environ.get('TRAVIS_PULL_REQUEST_BRANCH', '')
or os.environ.get('TRAVIS_BRANCH', '')
)
if branch:
_note(f"CI workflow detected; defaulting to branch '{branch}'", CLR_INFO)
_note(f"CI workflow detected; using branch '{branch}'", CLR_INFO)
scm = 'hg' if fetcher == 'hg' else 'git'
if not requests.get(repo).ok:
@ -636,7 +636,7 @@ def _clone(repo: str, into: str, branch: str, fetcher: str = 'github') -> bool:
if fetcher in {'github', 'gitlab', 'bitbucket'}:
options += ['--depth', '1']
elif scm == 'hg':
options = ['--branch', branch] if branch else []
options = ['--branch', branch if branch else 'default']
else:
_fail(f"Unrecognized SCM: {scm}")
return False