## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 2;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated by go2rpm 1.8.2
%bcond_without check

# https://github.com/cli/cli
%global goipath         github.com/cli/cli/v2
Version:                2.24.3

%gometa -f

%global goname          gh

%global common_description %{expand:
GitHub’s official command line tool.}

%global godevelheader   %{expand:
Obsoletes:              golang-github-cli-devel < 2.4.0-3
}
%global golicenses      LICENSE
%global godocs          README.md

Name:           %{goname}
Release:        %autorelease
Summary:        GitHub’s official command line tool

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

BuildRequires:  git-core
BuildRequires:  sed

Requires:       git-core

%description %{common_description}

%gopkg

%prep
%goprep

%generate_buildrequires
%go_generate_buildrequires

%build
export LDFLAGS="-X github.com/cli/cli/v2/internal/build.Version=%{version}  \
                -X github.com/cli/cli/v2/internal/build.Date=$(date -d "@${SOURCE_DATE_EPOCH}" +%Y-%m-%d)"
for cmd in cmd/%{name} cmd/gen-docs; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done

# Generate manpages
%{gobuilddir}/bin/gen-docs --man-page --doc-path ./share/man/man1

# Generate shell completions
%{gobuilddir}/bin/%{name} completion -s bash > %{name}.bash
%{gobuilddir}/bin/%{name} completion -s fish > %{name}.fish
%{gobuilddir}/bin/%{name} completion -s zsh  > %{name}.zsh


%install
%gopkginstall
# We are deliberately excluding cmd/gen-docs. It is only needed for building.
install -Dpm 0755 %{gobuilddir}/bin/%{name} -t %{buildroot}%{_bindir}/

# Install manpages
install -Dpm 0644 ./share/man/man1/%{name}*.1 -t %{buildroot}%{_mandir}/man1/

# Install shell completions
install -Dpm 0644 %{name}.bash %{buildroot}%{_datadir}/bash-completion/completions/%{name}
install -Dpm 0644 %{name}.fish %{buildroot}%{_datadir}/fish/vendor_completions.d/%{name}.fish
install -Dpm 0644 %{name}.zsh  %{buildroot}%{_datadir}/zsh/site-functions/_%{name}


%if %{with check}
%check
for test in "TestRebuildContainerIncremental" "TestStartJupyterServerSuccess" \
            "TestStartJupyterServerFailure" "TestStartSSHServerFailure" \
            "TestStartSSHServerSuccess" "TestRebuildContainerFull" \
            "TestRebuildContainerFailure" \
; do
awk -i inplace '/^func.*'"$test"'\(/ { print; print "\tt.Skip(\"disabled failing test\")"; next}1' $(grep -rl $test)
done
%gocheck
%endif

%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}
%{_mandir}/man1/%{name}*1*
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/%{name}
%dir %{_datadir}/fish
%dir %{_datadir}/fish/vendor_completions.d
%{_datadir}/fish/vendor_completions.d/%{name}.fish
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_%{name}

%gopkgfiles

%changelog
* Sat Mar 11 2023 Fabio Valentini <decathorpe@gmail.com> 2.24.3-2
- Rebuild for https://pagure.io/releng/issue/11327

* Sat Mar 11 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.24.3-1
- Update to 2.24.3 - Closes rhbz#2177095

* Thu Feb 09 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.23.0-1
- Update to 2.23.0 - Closes rhbz#2168105

* Sun Jan 29 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.22.1-1
- Update to 2.22.1 - Closes rhbz#2165276

* Fri Jan 27 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.22.0-1
- Update to 2.22.0 - Closes rhbz#2164529

* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> 2.21.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Thu Jan 05 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.21.2-1
- Update to 2.21.2 - Closes rhbz#2158295

* Sat Dec 24 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.21.1-2
- Update to 2.21.1 - Closes rhbz#2156132

* Sat Dec 24 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.21.1-1
- Update to 2.21.1 - Closes rhbz#2156132

* Fri Nov 18 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.20.2-2
- Skip test failing randomly in different arch

* Fri Nov 18 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.20.2-1
- Update to 2.20.2 - Closes rhbz#2140155

* Thu Oct 27 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.18.1-1
- Update to 2.18.1 - Closes rhbz#2136242

* Wed Oct 05 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.17.0-1
- Update to 2.17.0 - Closes rhbz#2132198

* Mon Sep 26 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.16.1-1
- Update to 2.16.1 - Closes rhbz#2129939

* Fri Sep 23 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.16.0-1
- Update to 2.16.0 - Closes rhbz#2129216

* Wed Sep 07 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.15.0-1
- Update to 2.15.0 - Closes rhbz#2124889

* Mon Sep 05 2022 Maxwell G <gotmax@e.email> 2.14.7-3
- Add patch to fix test failures with Go 1.16

* Fri Sep 02 2022 Maxwell G <gotmax@e.email> 2.14.7-2
- Fix test failure with cobra 1.5.0

* Fri Aug 26 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.14.7-1
- Update to 2.14.7 - Closes rhbz#2121666

* Wed Aug 24 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.14.6-1
- Update to 2.14.6 - Closes rhbz#2120892

* Thu Aug 11 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.14.4-1
- Update to 2.14.4

* Sat Jul 30 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.14.3-1
- Update to 2.14.3 - Closes rhbz#2111117

* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> 2.14.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

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

* Fri Jul 15 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.14.2-1
- Update to 2.14.2 - Closes rhbz#2107394

* Thu Jul 14 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.14.1-1
- Update to 2.14.1 - Closes rhbz#2106552

* Sat Jul 09 2022 Maxwell G <gotmax@e.email> 2.13.0-3
- Rebuild for CVE-2022-{24675,28327,29526 in golang}

* Sat Jul 09 2022 Maxwell G <gotmax@e.email> 2.13.0-2
- Rebuild for CVE-2022-{24675,28327,29526} in golang

* Fri Jun 24 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.13.0-1
- Update to 2.13.0 - Closes rhbz#2100252

* Sat Jun 18 2022 Robert-André Mauchin <zebob.m@gmail.com> 2.12.1-3
- Rebuilt for CVE-2022-1996, CVE-2022-24675, CVE-2022-28327,
  CVE-2022-27191, CVE-2022-29526, CVE-2022-30629

* Fri Jun 17 2022 Robert-André Mauchin <zebob.m@gmail.com> 2.12.1-2
- Rebuilt for CVE-2022-1996, CVE-2022-24675, CVE-2022-28327,
  CVE-2022-27191, CVE-2022-29526, CVE-2022-30629

* Tue Jun 14 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.12.1-1
- Update to 2.12.1 - Closes rhbz#2095582

* Wed Jun 08 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.12.0-1
- Update to 2.12.0 - Closes rhbz#2095044

* Thu May 26 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.11.3-1
- Update to 2.11.3 - Closes rhbz#2090679

* Wed May 25 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.11.1-1
- Update to 2.11.1 - Closes rhbz#2090123

* Tue May 24 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.11.0-1
- Update to 2.11.0 - Closes rhbz#2089851

* Wed May 11 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.10.1-1
- Update to 2.10.1 - Closes rhbz#2084080

* Fri Apr 29 2022 Onuralp SEZER <thunderbirdtr@fedoraproject.org> 2.9.0-1
- Update to 2.9.0 - Closes rhbz#2079112

* Sun Apr 17 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.8.0-1
- Update to 2.8.0 - Closes rhbz#2075721

* Sat Apr 16 2022 Fabio Alessandro Locati <me@fale.io> 2.7.0-2
- Rebuilt for CVE-2022-27191

* Wed Apr 06 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.7.0-1
- Update to 2.7.0

* Thu Mar 17 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.6.0-1
- Update to 2.6.0

* Wed Mar 02 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.5.2-1
- Update to 2.5.2

* Mon Feb 21 2022 Maxwell G <gotmax@e.email> 2.5.1-2
- Remove duplicate `BuildRequires:  go-rpm-macros`.

* Thu Feb 17 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.5.1-1
- Update to 2.5.1

* Thu Feb 03 2022 Maxwell G <gotmax@e.email> 2.5.0-2
- Fix forgeurl

* Wed Feb 02 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.5.0-1
- Update to 2.5.0

* Sat Jan 29 2022 Maxwell G <gotmax@e.email> 2.4.0-7
- Fix ldflags and rebuild for new go-rpm-macros.

* Tue Jan 25 2022 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.4.0-6
- Fix test that fails with golang-1.18 - Closes rhbz#2045415

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

* Tue Jan 18 2022 sixg0000d <sixg0000d@gmail.com> 2.4.0-4
- Fix: generate correct shell completions

* Wed Jan 12 2022 Maxwell G <gotmax@e.email> 2.4.0-3
- Fix %%%%goipath; generate manpages; fix dependencies

* Thu Dec 30 2021 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.4.0-1
- Update to 2.4.0. Closes rhbz#2034689

* Mon Dec 20 2021 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.3.0-2
- Skip a failing test with golang-1.18

* Mon Dec 20 2021 Mikel Olasagasti Uranga <mikel@olasagasti.info> 2.3.0-1
- Initial package - Fixes rhbz#2010367