MCPcopy Create free account
hub / github.com/ezyang/ghstack / run_pre_ghstack_hook

Function run_pre_ghstack_hook

src/ghstack/submit.py:1951–1970  ·  view source on GitHub ↗

If a `pre-ghstack` git hook is configured, run it.

(
    sh: ghstack.shell.Shell, base_commit: str, top_commit: str
)

Source from the content-addressed store, hash-verified

1949
1950
1951def run_pre_ghstack_hook(
1952 sh: ghstack.shell.Shell, base_commit: str, top_commit: str
1953) -> None:
1954 """If a `pre-ghstack` git hook is configured, run it."""
1955 default_hooks_path = os.path.join(
1956 sh.git("rev-parse", "--show-toplevel"), ".git/hooks"
1957 )
1958 try:
1959 hooks_path = sh.git(
1960 "config", "--default", default_hooks_path, "--get", "core.hooksPath"
1961 )
1962 hook_file = os.path.join(hooks_path, "pre-ghstack")
1963 except Exception as e:
1964 logging.warning(f"Pre ghstack hook failed: {e}")
1965 return
1966
1967 if not os.path.isfile(hook_file) or not os.access(hook_file, os.X_OK):
1968 return
1969
1970 sh.sh(hook_file, base_commit, top_commit, stdout=None)

Callers 1

runMethod · 0.85

Calls 2

gitMethod · 0.80
shMethod · 0.80

Tested by

no test coverage detected