# Generated by go2rpm 1.3

# The UI Tests fail upstream...
%bcond_with check

%undefine _missing_build_ids_terminate_build

# https://github.com/github/hub
%global goipath         github.com/github/hub
Version:                2.14.2

%gometa

%global common_description %{expand:
A command-line tool that makes git easier to use with GitHub}

%global golicenses      LICENSE
%global godocs          CONTRIBUTING.md CODE_OF_CONDUCT.md README.md\\\
                        etc/README.md share/man/man1/hub.1.md\\\
                        script/changelog features/README.md

Name:           %{goname}
Release:        9%{?dist}
Summary:        A command-line tool that makes git easier to use with GitHub

License:        MIT
URL:            %{gourl}
Source0:        %{gosource}

Patch0:         01-blackfriday-version.patch
Patch1:		02-use-system-cucumber.patch

BuildRequires:  golang(github.com/atotto/clipboard)
BuildRequires:  golang(github.com/BurntSushi/toml)
BuildRequires:  golang(github.com/kballard/go-shellquote)
BuildRequires:  golang(github.com/mattn/go-colorable)
BuildRequires:  golang(github.com/mattn/go-isatty)
BuildRequires:  golang(github.com/mitchellh/go-homedir)
BuildRequires:  golang(golang.org/x/crypto/ssh/terminal)
BuildRequires:  golang(golang.org/x/net/http/httpproxy)
BuildRequires:  golang(gopkg.in/russross/blackfriday.v2)
BuildRequires:  golang(gopkg.in/yaml.v2)
BuildRequires:  git-core
BuildRequires:  rubygem-cucumber
BuildRequires:  vim-filesystem
BuildRequires:  groff-base

Requires:       git-core
Requires:       vim-filesystem

%if %{with check}
# Tests
BuildRequires:  golang(github.com/bmizerany/assert)
%endif

%description
%{common_description}

%package -n hub
Summary: A command-line tool that makes git easier to use with GitHub
%description -n hub
%{common_description}

%prep
%goprep
%patch0 -p1
%patch1 -p1
rm -rf vendor/
rm -rf bundle/

%build
export LDFLAGS="-X github.com/github/hub/version.Version=%{version} "
%gobuild -o %{gobuilddir}/bin/hub %{goipath}
%gobuild -o bin/md2roff github.com/github/hub/md2roff-bin

# make man-pages uses bin/hub and if its not there, it'll try
# to make it...
if ! [ -e bin/hub ]; then
  ln -s %{gobuilddir}/bin/hub bin/hub
fi

# Make sure that `col` can handle UTF8 chars
export LC_ALL=C.UTF-8
export GOPATH=%{gopath}:$(pwd)/_build
%make_build man-pages

%install
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/

# Install man and vim files
for src in share/man/*/*.1 share/vim/vimfiles/*/*.vim; do
  dest="%{buildroot}%{_prefix}/${src}"
  mkdir -p "${dest%/*}"
  install -pm 0644 "$src" "$dest"
done

mv etc/README.md README-completion.md
mv features/README.md README-features.md
 
# Bash-completion
install -dm 755 %{buildroot}%{_datadir}/bash-completion/completions/
cp -p etc/hub.bash_completion.sh %{buildroot}%{_datadir}/bash-completion/completions/hub
 
# ZSH-completion
install -dm 755 %{buildroot}%{_datadir}/zsh/site-functions/
cp -p etc/hub.zsh_completion %{buildroot}%{_datadir}/zsh/site-functions/_hub
 
# FISH-completion
install -dm 755 %{buildroot}%{_datadir}/fish/completions/
cp -p etc/hub.fish_completion %{buildroot}%{_datadir}/fish/completions/hub.fish


%if %{with check}
%check
%gocheck
%endif

%files -n hub
%license LICENSE
%doc CONTRIBUTING.md CODE_OF_CONDUCT.md README.md README-completion.md
%doc share/man/man1/hub.1.md script/changelog README-features.md
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%dir %{_datadir}/fish
%dir %{_datadir}/fish/completions
%dir %{_datadir}/vim
%dir %{_datadir}/vim/vimfiles
%dir %{_datadir}/vim/vimfiles/ftdetect
%dir %{_datadir}/vim/vimfiles/syntax
%{_bindir}/*
%{_mandir}/man1/*
%{_datadir}/bash-completion/completions/hub
%{_datadir}/zsh/site-functions/_hub
%{_datadir}/fish/completions/hub.fish
%{_datadir}/vim/vimfiles/ftdetect/pullrequest.vim
%{_datadir}/vim/vimfiles/syntax/pullrequest.vim

%changelog
* Tue Jul 19 2022 Maxwell G <gotmax@e.email> - 2.14.2-9
- Rebuild for CVE-2022-{1705,32148,30631,30633,28131,30635,30632,30630,1962} in
  golang

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.14.2-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.14.2-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Sun Mar 07 2021 Phil Dibowitz <phil@ipom.com> - 2.14.2-6
- properly declare dirs with macro

* Sun Mar 07 2021 Phil Dibowitz <phil@ipom.com> - 2.14.2-5
- fix source - bad tarball was being uploaded
- own directories
- nuke vendor and bundle in prep

* Fri Mar 05 2021 Phil Dibowitz <phil@ipom.com> - 2.14.2-4
- pull in fixes from abandoned package
- add manpages, vim files, and tab completion
- drop unnecessary subpackages

* Thu Mar 04 05:51:41 UTC 2021 Phil Dibowitz <phil@ipom.com> - 2.14.2-3
- Fix patch that fixes blackfriday imports (/v2 vs .v2)

* Sun Feb 28 05:51:41 UTC 2021 Phil Dibowitz <phil@ipom.com> - 2.14.2-2
- Fix blackfriday imports

* Sun Feb 28 05:51:41 UTC 2021 Phil Dibowitz <phil@ipom.com> - 2.14.2-1
- Initial package