dolthub / dolthub/doltcli

Reset to specific revision

Open
#40 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14
Forks
9
PR merge metrics
No merged PRs in 30d

Description

I would like to `reset HEAD~1 --hard `, so reset to a specific revision / drop the last commit.

Right now it's not clear to me how to pass the revision to the `Dolt.reset()` method.

A possible solution could be adding the revision as the first parameter (not passing via kwargs) and appending it to `args` before `--soft` / `--hard` :

```python
def reset(
self,
revision: str,
tables: Union[str, List[str]] = [],
hard: bool = False,
soft: bool = False,
**kwargs,
):
"""
Reset a table or set of tables that have changes in the working set to their value at the tip of the current
branch.
:param tables:
:param hard:
:param soft:
:return:
"""
if not isinstance(tables, (str, list)):
raise ValueError(
f"tables should be: Union[str, List[str]]; found {type(tables)}"
)

to_reset = to_list(tables)

args = ["reset"]

if hard and soft:
raise ValueError("Specify one of: hard=True, soft=True")

if (hard or soft) and to_reset:
raise ValueError("Specify either hard/soft flag, or tables to reset")

args.append(revision)

if hard:
args.append("--hard")
elif soft:
args.append("--soft")
elif not tables:
args.append("--soft")
else:
args += to_reset

self.execute(args, **kwargs)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.