{% set version = "2.40.1" %}

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: 55511f10f3b1cdf5db4e0e3dea61819dfb67661b0507a5a2b061c70e4f87e14c  # [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: 6bbde434121bd0bf8aa574c60fd9a162388383679bd5ddd99921505149ffd4c2  # [not win]
  - url: https://mirrors.edge.kernel.org/pub/software/scm/git/git-htmldocs-{{ version }}.tar.gz  # [not win]
    folder: htmldocs  # [not win]
    sha256: 4fcce89aa84c79be6641fee54cf05c590c7d967734536770bf6299cae26c8a51  # [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: 9e1d819aef3284420adf6d923b0d4865254bd403641d915975e49ddea1e7cdf9  # [win64]


build:
  number: 1
  # git hardcodes paths to external utilities (e.g. curl)
  detect_binary_files_with_prefix: true
  missing_dso_whitelist:    # [win]
    - '*'                   # [win]

requirements:
  build:
    - {{ compiler('c') }}  # [unix]
    - autoconf  # [unix]
    - make      # [unix]
    - 7za       # [win]
    - tk        # [unix]
    - gettext   # [unix]
    - patch     # [unix]
  host:
    - curl 7.88.1  # [unix]
    - libcurl 7.88.1  # [unix]
    - expat 2.4.9  # [unix]
    - libiconv 1.16  # [osx]
    - openssl {{ openssl }}  # [unix]
    - pcre2 10.42  # [unix]
    - perl 5.*  # [unix]
    - zlib 1.2.13  # [unix]
  run:
    - curl      # [unix]
    - libcurl   # [unix]
    - expat     # [unix]
    - gettext   # [unix]
    - libiconv  # [osx]
    # exact pin handled through openssl run_exports
    - 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]

    # 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/
  description: |
    Git is a distributed version control system that tracks changes in any set of computer files,
    usually used for coordinating work among programmers collaboratively developing source code during software development.
  license: GPL-2.0-or-later and LGPL-2.1-or-later
  license_file: code/COPYING  # [not win]
  license_url: https://raw.githubusercontent.com/git-for-windows/git/v2.40.1.windows.1/COPYING  # [win]
  license_family: OTHER
  summary: distributed version control system
  dev_url: https://github.com/git/git
  doc_url: https://git-scm.com/docs

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