MCPcopy
hub / github.com/treeverse/dvc / _run

Method _run

dvc/commands/git_hook.py:35–55  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

33
34class CmdPostCheckout(CmdHookBase):
35 def _run(self):
36 # when we are running from pre-commit tool, it doesn't provide CLI
37 # flags, but instead provides respective env vars that we could use.
38 flag = os.environ.get("PRE_COMMIT_CHECKOUT_TYPE")
39 if flag is None and len(self.args.args) >= 3:
40 # see https://git-scm.com/docs/githooks#_post_checkout
41 flag = self.args.args[2]
42
43 # checking out some reference and not specific file.
44 if flag != "1":
45 return 0
46
47 # make sure we are not in the middle of a rebase/merge, so we
48 # don't accidentally break it with an unsuccessful checkout.
49 # Note that git hooks are always running in repo root.
50 if os.path.isdir(os.path.join(".git", "rebase-merge")):
51 return 0
52
53 from dvc.cli import main
54
55 return main(["checkout"])
56
57
58class CmdPrePush(CmdHookBase):

Callers

nothing calls this directly

Calls 4

mainFunction · 0.90
isdirMethod · 0.80
joinMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected