%global goipath github.com/git-lfs/git-lfs

Name:           git-lfs
Version:        2.8.0
Release:        1%{?dist}
Summary:        Git extension for versioning large files
License:        MIT
URL:            https://git-lfs.github.io/
Source0:        https://github.com/%{name}/%{name}/releases/download/v%{version}/%{name}-v%{version}.tar.gz
# https://github.com/git-lfs/git-lfs/issues/3798
Patch0001:      https://github.com/git-lfs/git-lfs/pull/3800.patch
Patch0002:      https://github.com/git-lfs/git-lfs/pull/3771.patch
BuildRequires:  golang
BuildRequires:  perl-Digest-SHA
BuildRequires:  perl-Test-Harness
# Tests require full git suite, but not generally needed.
BuildRequires:  git >= 1.8.5
Requires:       git-core >= 1.8.5


%description
Git Large File Storage (LFS) replaces large files such as audio samples,
videos, datasets, and graphics with text pointers inside Git, while
storing the file contents on a remote server.


%package -n %{name}-devel
Summary:       %{summary}
BuildArch:     noarch
%description -n %{name}-devel
%{summary}
This package contains library source intended for building other packages
which use import path with %{goipath} prefix.


%prep
%autosetup -p1
# Modify Makefile so that it expects binaries where we build them.
sed -i -e 's!/bin/!/_bin/!g' t/Makefile


%build
%gobuildroot
# Build manpages first (some embedding in the executable is done.)
pushd docs
%gobuild -o ../_bin/mangen man/mangen.go
../_bin/mangen
popd
%gobuild -o _bin/git-lfs %{goipath}
# Build test executables
for go in t/cmd/*.go; do
    %gobuild -o "_bin/$(basename $go .go)" "$go"
done
%gobuild -o "_bin/git-lfs-test-server-api" t/git-lfs-test-server-api/*.go


%install
%goinstall
install -Dpm0755 _bin/git-lfs %{buildroot}%{_bindir}/%{name}


%post
%{_bindir}/%{name} install --system --skip-repo

%preun
if [ $1 -eq 0 ]; then
    %{_bindir}/%{name} uninstall --system --skip-repo
fi
exit 0



%files
%doc README.md CHANGELOG.md
%license LICENSE.md
%{_bindir}/%{name}


%files -n %{name}-devel -f devel.file-list
%license LICENSE.md


%changelog
