Skip to main content

resolve_developer_git

Function resolve_developer_git 

Source
pub fn resolve_developer_git(
    developer_dir: Option<&OsStr>,
    select_link_target: Option<&Path>,
    is_file: impl Fn(&Path) -> bool,
) -> Option<PathBuf>
Expand description

The macOS developer Git. Pure (the caller supplies DEVELOPER_DIR, the target of /var/db/xcode_select_link and the file test), so it builds and is tested on every platform. Candidate directories, in order:

  1. developer_dir (DEVELOPER_DIR), if set and absolute;
  2. select_link_target, if absolute;
  3. /Applications/Xcode.app/Contents/Developer;
  4. /Library/Developer/CommandLineTools.

For each, <dir>/usr/bin/git, then <dir>/Contents/Developer/usr/bin/git (a directory given as the .app bundle, as xcrun accepts). The first that is_file accepts wins. A candidate that is set but has no Git falls through to the next one. Relative candidates and ones with .. are skipped, and the result is never /usr/bin/git, even if a candidate is /. None means there is no developer Git; there is no PATH lookup.