From d4d6139b20a65460444d3ab04693d6762cea04d3 Mon Sep 17 00:00:00 2001 From: Nick Crews Date: Mon, 2 May 2022 13:54:08 -0600 Subject: [PATCH 1/5] BUG: Allow branches that conflict with file names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, if I had a file named "benchmarks" and a branch specified in asv.conf.json also named "benchmarks", then when I ran `asv publish` I would get ``` $ asv publish [ 11.11%] · Loading machine info [ 22.22%] · Getting params, commits, tags and branches [ 22.22%] ·· Error running /usr/local/bin/git rev-list --first-parent benchmarks (exit status 128) STDOUT --------> STDERR --------> fatal: ambiguous argument 'benchmarks': both revision and filename Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' Traceback (most recent call last): File "/Users/nickcrews/Documents/projects/dedupe/.venv/bin/asv", line 8, in sys.exit(main()) .... ``` Tested locally, it works fine now. --- asv/plugins/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/asv/plugins/git.py b/asv/plugins/git.py index 6ff9dc61e..df02ce71f 100644 --- a/asv/plugins/git.py +++ b/asv/plugins/git.py @@ -119,7 +119,7 @@ def get_date(self, hash): def get_hashes_from_range(self, range_spec): args = ['rev-list', '--first-parent'] if range_spec != "": - args += shlex.split(range_spec) + args += shlex.split(range_spec) + ["--"] output = self._run_git(args, valid_return_codes=(0, 1), dots=False) return output.strip().split() From 2defb31ba1ec1c7578fb6f37e6f5850a111c6d3b Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Thu, 11 May 2023 23:40:06 +0000 Subject: [PATCH 2/5] TST: Add branch bug test for gh-1209 --- test/test_publish.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test_publish.py b/test/test_publish.py index 28dfb07fa..c64825f0a 100644 --- a/test/test_publish.py +++ b/test/test_publish.py @@ -2,9 +2,11 @@ import datetime import os import shutil +import subprocess import xml.etree.ElementTree as etree from os.path import abspath, dirname, join, isfile, isdir +import json5 import pytest try: @@ -432,3 +434,27 @@ def test_regression_atom_feed_update(dvcs_type, tmpdir): a_content = a.find('{http://www.w3.org/2005/Atom}content') b_content = b.find('{http://www.w3.org/2005/Atom}content') assert a_content.text != b_content.text + +def test_gh1209(tmpdir): + tmpdir = str(tmpdir) + dvcs = tools.generate_test_repo(tmpdir, list(range(10)), + dvcs_type="git", + extra_branches=[(f"{util.git_default_branch()}~4", + "benchmarks", [11, 12, 13])]) + subprocess.run(["asv", "quickstart", "--top-level"], + cwd=dvcs.path, check=True) + with open(f"{dvcs.path}/asv.conf.json", 'r+') as fhandle: + conf = json5.load(fhandle) + conf["branches"] = ["benchmarks"] + conf["dvcs"] = "git" + fhandle.seek(0) + json5.dump(conf, fhandle, indent=4) + fhandle.truncate() + subprocess.run(["asv", "machine", "--yes"], + cwd=dvcs.path, check=True) + subprocess.run(["asv", "run"], + cwd=dvcs.path, check=True) + retdat = subprocess.run(["asv", "publish"], cwd=dvcs.path, + capture_output=True, text=True) + assert "git rev-list --first-parent benchmarks" not in retdat.stderr + assert retdat.returncode == 0 From ebf26b8ed1cad79fec43e97ef4b7d874933c60de Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Fri, 12 May 2023 00:35:35 +0000 Subject: [PATCH 3/5] BLD: Add to appveyor for test --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index f6061c4d1..d05cf26df 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -25,7 +25,7 @@ install: - conda update conda -y - conda install -q --yes python=%PYTHON_VERSION% conda pip pytest pytest-xdist pytest-timeout filelock selenium conda-build bzip2 pympler rpy2 - python -m pip install -U pip - - python -m pip install pytest-rerunfailures json5 pympler tabulate colorama + - python -m pip install pytest-rerunfailures json5 pympler tabulate colorama virtualenv # Check that we have the expected version of Python - python --version From 713a4c1c5b47cdddbf8e0442ab72dc71401d2930 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Fri, 12 May 2023 00:58:16 +0000 Subject: [PATCH 4/5] TST: Don't check asv in subprocesses --- test/test_publish.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_publish.py b/test/test_publish.py index c64825f0a..d16c5f746 100644 --- a/test/test_publish.py +++ b/test/test_publish.py @@ -451,9 +451,9 @@ def test_gh1209(tmpdir): json5.dump(conf, fhandle, indent=4) fhandle.truncate() subprocess.run(["asv", "machine", "--yes"], - cwd=dvcs.path, check=True) + cwd=dvcs.path, check=False) subprocess.run(["asv", "run"], - cwd=dvcs.path, check=True) + cwd=dvcs.path, check=False) retdat = subprocess.run(["asv", "publish"], cwd=dvcs.path, capture_output=True, text=True) assert "git rev-list --first-parent benchmarks" not in retdat.stderr From 848d666ed6b5cdd8810d4415897766c85a6f7a52 Mon Sep 17 00:00:00 2001 From: Rohit Goswami Date: Sun, 14 May 2023 17:32:47 +0000 Subject: [PATCH 5/5] TST: Rename to be clearer Co-authored-by: mattip --- test/test_publish.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_publish.py b/test/test_publish.py index d16c5f746..9021e0612 100644 --- a/test/test_publish.py +++ b/test/test_publish.py @@ -435,7 +435,8 @@ def test_regression_atom_feed_update(dvcs_type, tmpdir): b_content = b.find('{http://www.w3.org/2005/Atom}content') assert a_content.text != b_content.text -def test_gh1209(tmpdir): +def test_branch_name_is_also_filename(tmpdir): + # gh-1209 tmpdir = str(tmpdir) dvcs = tools.generate_test_repo(tmpdir, list(range(10)), dvcs_type="git",