Skip to content

Reset to specific revision #40

@alessiamarcolini

Description

@alessiamarcolini

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions