{% set version = "2.32.0" %}

package:
  name: git
  version: {{ version }}

source:
  - url: https://mirrors.edge.kernel.org/pub/software/scm/git/git-{{ version }}.tar.gz  # [not win]
    folder: code  # [not win]
    sha256: 6038f06d396ba9dab2eee541c7db6e7f9f847f181ec62f3d8441893f8c469398  # [not win]
    patches:   # [not win]
      - 0001-macOS-Do-not-use-the-system-Wish-urgh.patch  # [not win]
  - url: https://mirrors.edge.kernel.org/pub/software/scm/git/git-manpages-{{ version }}.tar.gz  # [not win]
    folder: manpages  # [not win]
    sha256: b5533c40ea1688231c0e2df51cc0d1c0272e17fe78a45ba6e60cb8f61fa4a53c  # [not win]
  - url: https://mirrors.edge.kernel.org/pub/software/scm/git/git-htmldocs-{{ version }}.tar.gz  # [not win]
    folder: htmldocs  # [not win]
    sha256: e38c525084355612cad6358e64361a0eaae5901f91460074f8f913dea702ee4c  # [not win]

  - url: https://github.com/git-for-windows/git/releases/download/v{{ version }}.windows.1/PortableGit-{{ version }}-64-bit.7z.exe  # [win64]
    folder: .  # [win64]
    sha256: cc561200eb89fdb19c75f901aea2740ffa57a627a31c1a6ef86a8d37e3186275  # [win64]

build:
  number: 1
  # git hardcodes paths to external utilities (e.g. curl)
  detect_binary_files_with_prefix: true

requirements:
  build:
    - {{ compiler('c') }}  # [unix]
    - autoconf  # [unix]
    - make      # [unix]
    - 7za       # [win]
    - tk        # [unix]
    - gettext   # [unix]
  host:
    - curl      # [unix]
    - expat     # [unix]
    - libiconv  # [unix and not ppc64le]
    - openssl   # [unix]
    - pcre2     # [unix]
    - perl 5.*  # [unix]
    - zlib      # [unix]
  run:
    - curl      # [unix]
    - expat     # [unix]
    - gettext   # [unix]
    - libiconv  # [unix and not ppc64le]
    - openssl   # [unix]
    - pcre2     # [unix]
    - perl 5.*  # [unix]
    - tk        # [unix]
    - zlib      # [unix]

test:
  commands:
    # Verify git location.
    - test -f $PREFIX/bin/git                               # [unix]
    - test -f $PREFIX/bin/gitk                              # [unix]
    - test -f $PREFIX/bin/git-credential-osxkeychain        # [osx]
    - if not exist %LIBRARY_PREFIX%\\bin\\git.exe exit 1    # [win]

    # Verify interactive support.
    - test -f $PREFIX/libexec/git-core/git-add--interactive  # [unix]

    # Run git commands.
    - git --version
    - git clone https://github.com/conda-forge/git-feedstock

    # Git credential commands
    - git-credential-osxkeychain 2>&1 | grep -q usage  # [osx]

    # test completions
    - bash $PREFIX/share/bash-completion/completions/git  # [unix]

    # confirm toplevel manpage
    - test -f $PREFIX/man/man1/git.1  # [not win]
    - test -f $PREFIX/share/man/man1/git.1  # [osx]

    # confirm toplevel html doc page
    - test -f $PREFIX/share/doc/git/index.html  # [not win]

about:
  home: https://git-scm.com/
  license: GPL-2.0-or-later and LGPL-2.1-or-later
  license_file: code/COPYING  # [not win]
  summary: distributed version control system

extra:
  recipe-maintainers:
    - jakirkham
    - msarahan
    - pelson
    - scopatz
    - ocefpaf
    - djsutherland
