Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset to specific revision #40

Open
alessiamarcolini opened this issue Feb 7, 2023 · 2 comments
Open

Reset to specific revision #40

alessiamarcolini opened this issue Feb 7, 2023 · 2 comments

Comments

@alessiamarcolini
Copy link
Contributor

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 :

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)
@timsehn
Copy link

timsehn commented Feb 7, 2023

We don't actively maintain the Dolt python interface.

We've moved most of our effort to supporting the SQL interface because that works in every language.

This seems like a simple patch though. I'll see if I can get someone to crank it out.

@max-hoffman
Copy link
Collaborator

I think this PR should help expose the revision parameter to match our CLI more closely: #41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants