Skip to content

proposal: add command to determine if commit is ancestor of module version #59

@myitcv

Description

@myitcv

I'm not entirely sure this belongs in gohack, but given the -vcs flag gohack makes answering it possible. So raising here for discussion at least.

I'm trying to answer the following question:

Given commit $commit, are we currently using a version of module $m that that has $commit as an ancestor?

The answer is in effect given by this sequence of commands:

GOHACK=$(mktemp -d) gohack get -vcs golang.org/x/tools
pushd $(go list -m -f {{.Replace.Dir}} golang.org/x/tools)
answer=$(git merge-base --is-ancestor $commit HEAD && echo "yes" || echo "no")
popd
gohack undo golang.org/x/tools

Does it make sense to provide a gohack command that answers this question?

cc @rogpeppe @mvdan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions