Look for hooks inside the repository to run.
198512
def autohook(ui, repo, hooktype, **kwargs):
    """"""
    cmd = hooktype.replace("-", "_")
    if not repo or not cmd.replace("_", "").isalpha():
        return False
    result = False
    trusted = ui.configlist("autohooks", "trusted")
    if "" not in trusted:
        default_path = ui.config("paths", "default")
        if not default_path:
            return False
        for match in trusted:
            if default_path.startswith(match):
                break
        else:
            return False
    for hookdir in ("hg-autohooks", ".hg-autohooks"):
        dirname = os.path.join(repo.root, hookdir)
        if not os.path.exists(dirname):
            continue
        for leafname in os.listdir(dirname):
            if not leafname.startswith(cmd + "."):
                continue
            filename = os.path.join(dirname, leafname)
            result = _runhook(ui, repo, hooktype, filename, kwargs) or result
    return result
710389
def dispatch_hook(key, hooks, hook_data, **kwargs):
    """"""
    hooks = hooks or {}
    hooks = hooks.get(key)
    if hooks:
        if hasattr(hooks, '__call__'):
            hooks = [hooks]
        for hook in hooks:
            _hook_data = hook(hook_data, **kwargs)
            if _hook_data is not None:
                hook_data = _hook_data
    return hook_data
974433
function runHooks(hooks, args, callback) {
    console.log('*** git-hooks.js runHooks', hooks, args);
    if (!hooks.length) {
        callback(0);
        return;
    }
    try {
        var hook = spawnHook(hooks.shift(), args);
        hook.on('close', function (code) {
            if (code === 0) {
                runHooks(hooks, args, callback);
            } else {
                callback(code);
            }
        });
    } catch (e) {
        callback(1, e);
    }
}
488995
def get_package_sources(self):
        """"""
        # Checkout local modules
        for config in self.sources.get('local', []):
            self.fetch_local_package(config=config)
        # Checkout S3 repositories specified in config
        for config in self.sources.get('s3', []):
            self.fetch_s3_package(config=config)
        # Checkout git repositories specified in config
        for config in self.sources.get('git', []):
            self.fetch_git_package(config=config)
1321321
function (workingDirectory) {
        var gitPath = getClosestGitPath(workingDirectory);

        if (!gitPath) {
            throw new Error('git-hooks must be run inside a git repository');
        }

        var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
        var hooksOldPath = path.resolve(gitPath, HOOKS_OLD_DIRNAME);

        if (!fsHelpers.exists(hooksPath)) {
            throw new Error('git-hooks is not installed');
        }

        fsHelpers.removeDir(hooksPath);

        if (fsHelpers.exists(hooksOldPath)) {
            fs.renameSync(hooksOldPath, hooksPath);
        }
    }
81836
def run_hook(hook_name, *args, &block)
      hooks.find {|hook| hook.name == hook_name }.run(self, *args, &block)
    end
655293
function executeHooks(data, allHooks, checkHooks, creationMode) {
    var hooksToCall = creationMode ? allHooks : checkHooks;
    if (hooksToCall) {
        callHooks(data, hooksToCall);
    }
}
281715
function (filename, arg, callback) {
      console.log('*** git-hooks.js run', filename, arg);
        var hookName = path.basename(filename);
        var hooksDirname = path.resolve(path.dirname(filename), '../../.githooks', hookName);

        if (fsHelpers.exists(hooksDirname)) {
            var list = fs.readdirSync(hooksDirname);
            var hooks = list.map(function (hookName) {
                return path.resolve(hooksDirname, hookName);
            });
            excludeIgnoredPaths(hooks, function (filteredHooks) {
                runHooks(filteredHooks, [arg], callback);
            });
        } else {
            callback(0);
        }
    }
387756
def get_hooks(self):
    """"""
    if self.__hooks is None and self.hooks_class_name is not None:
      hooks_class = util.for_name(self.hooks_class_name)
      if not isinstance(hooks_class, type):
        raise ValueError("hooks_class_name must refer to a class, got %s" %
                         type(hooks_class).__name__)
      if not issubclass(hooks_class, hooks.Hooks):
        raise ValueError(
            "hooks_class_name must refer to a hooks.Hooks subclass")
      self.__hooks = hooks_class(self)

    return self.__hooks
502542
def determine_hooks(self, controller=None):
        '''
        
        '''

        controller_hooks = []
        if controller:
            controller_hooks = _cfg(controller).get('hooks', [])
            if controller_hooks:
                return list(
                    sorted(
                        chain(controller_hooks, self.hooks),
                        key=operator.attrgetter('priority')
                    )
                )
        return self.hooks
860198
def _run_hooks(self, name, module):
        
        hooks = self.post_load_hooks.pop(name, [])

        for hook in hooks:
            hook(module)
594659
function Hook(fn, options) {
  if (!this) return new Hook(fn, options);
  options = options || {};

  this.options = options;     // Used for testing only. Ignore this. Don't touch.
  this.config = {};           // pre-commit configuration from the `package.json`.
  this.json = {};             // Actual content of the `package.json`.
  this.npm = '';              // The location of the `npm` binary.
  this.git = '';              // The location of the `git` binary.
  this.root = '';             // The root location of the .git folder.
  this.status = '';           // Contents of the `git status`.
  this.exit = fn;             // Exit function.

  this.initialize();
}
796455
def _hooks_apply_after_parse(
        hooks,  # type: Optional[Hooks]
        state,  # type: _ProcessorState
        value  # type: Any
):
    # type: (...) -> Any
    """"""
    if hooks and hooks.after_parse:
        return hooks.after_parse(ProcessorStateView(state), value)

    return value
640954
def trigger_hook(self, __name, *args, **kwargs):
        '''  '''
        return [hook(*args, **kwargs) for hook in self._hooks[__name][:]]
1215885
def create_hook(self, repo_id, repo_name):
        """"""
        config = dict(
            url=self.webhook_url,
            content_type='json',
            secret=current_app.config['GITHUB_SHARED_SECRET'],
            insecure_ssl='1' if current_app.config['GITHUB_INSECURE_SSL']
                         else '0',
        )

        ghrepo = self.api.repository_with_id(repo_id)
        if ghrepo:
            try:
                hook = ghrepo.create_hook(
                    'web',  # GitHub identifier for webhook service
                    config,
                    events=['release'],
                )
            except github3.GitHubError as e:
                # Check if hook is already installed
                hook_errors = (m for m in e.errors
                               if m['code'] == 'custom' and
                               m['resource'] == 'Hook')
                if next(hook_errors, None):
                    hooks = (h for h in ghrepo.hooks()
                             if h.config.get('url', '') == config['url'])
                    hook = next(hooks, None)
                    if hook:
                        hook.edit(config=config, events=['release'])
            finally:
                if hook:
                    Repository.enable(user_id=self.user_id,
                                      github_id=repo_id,
                                      name=repo_name,
                                      hook=hook.id)
                    return True
        return False
593079
def hook(module):
    
    if "INSTANA_DEV" in os.environ:
        print("==============================================================")
        print("Instana: Running flask hook")
        print("==============================================================")
    wrapt.wrap_function_wrapper('flask', 'Flask.__init__', wrapper)
290790
def _load_github_hooks(github_url='https://api.github.com'):
    
    try:
        resp = requests.get(github_url + '/meta')
        if resp.status_code == 200:
            return resp.json()['hooks']
        else:
            if resp.headers.get('X-RateLimit-Remaining') == '0':
                reset_ts = int(resp.headers['X-RateLimit-Reset'])
                reset_string = time.strftime('%a, %d %b %Y %H:%M:%S GMT',
                                             time.gmtime(reset_ts))
                raise ServiceUnavailable('Rate limited from GitHub until ' +
                                         reset_string)
            else:
                raise ServiceUnavailable('Error reaching GitHub')
    except (KeyError, ValueError, requests.exceptions.ConnectionError):
        raise ServiceUnavailable('Error reaching GitHub')