Skip to content

Commit

Permalink
reset revision (#41)
Browse files Browse the repository at this point in the history
* allow replace

* Add reset revision arg
  • Loading branch information
max-hoffman authored Feb 14, 2023
1 parent fd79aa2 commit 5b61a7e
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 112 deletions.
7 changes: 7 additions & 0 deletions doltcli/dolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ def add(self, tables: Union[str, List[str]], **kwargs) -> Status:
def reset(
self,
tables: Union[str, List[str]] = [],
revision: str = "",
hard: bool = False,
soft: bool = False,
**kwargs,
Expand All @@ -432,6 +433,12 @@ def reset(
if (hard or soft) and to_reset:
raise ValueError("Specify either hard/soft flag, or tables to reset")

if to_reset and revision != "":
raise ValueError("Specify either revision or tables to reset")

if revision != "":
args.append(revision)

if hard:
args.append("--hard")
elif soft:
Expand Down
142 changes: 39 additions & 103 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ authors = ["Max Hoffman <max@dolthub.com>", "Oscar Batori <oscar@dolthub.com>"]
[tool.poetry.dependencies]
python = ">=3.6.2,<4.0"
dataclasses = {version = ">=0.6", markers = "python_version < \"3.7\""}
"typed-ast" = ">1.4.3"

[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
black = "^21.10b0"
mypy = "0.800"
mypy = ">0.800"
pytest-cov = "^2.11.1"
isort = "^5.9.1"
flake8 = "^3.9.2"
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ def doltdb():
db = Dolt.init(db_path)
db.sql("create table t1 (a bigint primary key, b bigint, c bigint)")
db.sql("insert into t1 values (1,1,1), (2,2,2)")
db.sql("select dolt_add('t1')")
db.sql("select dolt_commit('-m', 'initialize t1')")
db.sql("call dolt_add('t1')")
db.sql("call dolt_commit('-m', 'initialize t1')")

db.sql("insert into t1 values (3,3,3)")
db.sql("select dolt_add('t1')")
db.sql("select dolt_commit('-m', 'edit t1')")
db.sql("call dolt_add('t1')")
db.sql("call dolt_commit('-m', 'edit t1')")
yield db_path
finally:
if os.path.exists(db_path):
Expand Down
12 changes: 8 additions & 4 deletions tests/test_dolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,13 @@ def test_merge_conflict(create_test_table):

# merge
repo.checkout("main")
repo.merge("other", message_merge)
with pytest.raises(DoltException):
repo.merge("other", message_merge)

commits = list(repo.log().values())
head_of_main = commits[0]
#commits = list(repo.log().values())
#head_of_main = commits[0]

assert head_of_main.message == message_two
#assert head_of_main.message == message_two


def test_dolt_log(create_test_table):
Expand Down Expand Up @@ -636,6 +637,9 @@ def test_reset(doltdb):
db.reset(soft=True)
db.reset(tables="t1")
db.reset(tables=["t1"])
db.reset(revision="head~1", soft=True)
with pytest.raises(ValueError):
db.reset(tables=["t1"], revision="head~1")


def test_reset_errors(doltdb):
Expand Down

0 comments on commit 5b61a7e

Please sign in to comment.