{% set version = "2.45.2" %}

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: 98b26090ed667099a3691b93698d1e213e1ded73d36a2fde7e9125fce28ba234  # [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: 48c1e2e3ecbb2ce9faa020a19fcdbc6ce64ea25692111b5930686bc0bb4f0e7f  # [not win]
  - url: https://mirrors.edge.kernel.org/pub/software/scm/git/git-htmldocs-{{ version }}.tar.gz  # [not win]
    folder: htmldocs  # [not win]
    sha256: 5fe5c94364637f08928d081d377e15bbd0e74d56bdec794c2e9ed3a9fdedc8a9  # [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: 851a15074dea6b272785b2a2a4697a72970256de2afe7b8e4a9c5e168c27ccdd  # [win64]


build:
  number: 0
  # 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]
    - tk           # [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
