## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    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.10.0
%bcond_without check

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

%gometa -L -f

%global common_description %{expand:
A command-line interface to GitHub for use in your terminal or your scripts.

gh is a tool designed to enhance your workflow when working with GitHub. It
provides a seamless way to interact with GitHub repositories and perform various
actions right from the command line, eliminating the need to switch between your
terminal and the GitHub website.}

%global golicenses      LICENSE
%global godocs          README.md

Name:           gh
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 -A
%autopatch -p1

%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
# 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}%{bash_completions_dir}/%{name}
install -Dpm 0644 %{name}.fish %{buildroot}%{fish_completions_dir}/%{name}.fish
install -Dpm 0644 %{name}.zsh  %{buildroot}%{zsh_completions_dir}/_%{name}


%if %{with check}
%check
# TestHTTPClientSanitizeJSONControlCharactersC0 fails as needs to be updated for 1.22 changes
for test in "TestRebuildContainerIncremental" "TestStartJupyterServerSuccess" \
            "TestStartJupyterServerFailure" "TestStartSSHServerFailure" \
            "TestStartSSHServerSuccess" "TestRebuildContainerFull" \
            "TestRebuildContainerFailure" "TestHTTPClientSanitizeJSONControlCharactersC0" \
; 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*
%{bash_completions_dir}/%{name}
%{fish_completions_dir}/%{name}.fish
%{zsh_completions_dir}/_%{name}

%changelog
## START: Generated by rpmautospec
* Thu Mar 21 2024 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.46.0-1
- Update to 2.46.0 - Closes rhbz#2270843

* Tue Mar 05 2024 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.45.0-1
- Update to 2.45.0 - Closes rhbz#2267863

* Sun Feb 18 2024 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.44.1-1
- Update to 2.44.1 - Closes rhbz#2264474

* Sun Feb 11 2024 Maxwell G <maxwell@gtmx.me> - 2.43.1-2
- Rebuild for golang 1.22.0

* Mon Feb 05 2024 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.43.1-1
- Update to 2.43.1 - Closes rhbz#2258884

* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.42.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.42.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Thu Jan 11 2024 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.42.0-1
- Update to 2.42.0 - Closes rhbz#2257927

* Mon Jan 08 2024 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.41.0-1
- Update to 2.41.0 - Closes rhbz#2257273 rhbz#2255084

* Fri Dec 15 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.40.1-1
- Update to 2.40.1 - Closes rhbz#2253744

* Sat Dec 09 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.40.0-1
- Update to 2.40.0 - Closes rhbz#2253744

* Tue Nov 28 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.39.2-1
- Update to 2.39.2 - Closes rhbz#2251883

* Wed Nov 15 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.39.1-1
- Update to 2.39.1 - Closes rhbz#2249773 rhbz#2248270

* Fri Nov 03 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.38.0-1
- Update to 2.38.0 - Closes rhbz#2247708

* Wed Oct 18 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.37.0-1
- Update to 2.37.0 - Closes rhbz#2244886

* Wed Oct 04 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.36.0-1
- Update to 2.36.0 - Closes rhbz#2242160

* Sun Sep 24 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.35.0-1
- Update to 2.35.0 - Closes rhbz#2237952

* Wed Aug 23 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.33.0-1
- Update to 2.33.0 - Closes rhbz#2233559 rhbz#2229593

* Wed Jul 26 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.32.1-1
- Update to 2.32.1 - Closes rhbz#2225398

* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.32.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Mon Jul 17 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.32.0-1
- Update to 2.32.0 - Closes rhbz#2222159

* Sat Jun 24 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.31.0-1
- Update to 2.31.0 - Closes rhbz#2216708

* Sat Jun 03 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.30.0-2
- Fix non-ascii chars in Summary and extend Description

* Wed May 31 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.30.0-1
- Update to 2.30.0 - Closes rhbz#2211264

* Fri May 12 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.29.0-1
- Update to 2.29.0 - Closes rhbz#2198539

* Tue Apr 25 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.28.0-1
- Update to 2.28.0 - Closes rhbz#2189554

* Tue Apr 11 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.27.0-1
- Update to 2.27.0 - Closes rhbz#2185391

* Wed Apr 05 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.26.1-1
- Update to 2.26.1 - Closes rhbz#2184533

* Mon Apr 03 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.25.1-2
- Fix codespace connection issue - Closes rhbz#2175969

* Wed Mar 22 2023 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.25.1-1
- Update to 2.25.1 - Closes rhbz#2180521

* 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-2
- Add missing sources

* 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

* Fri Dec 31 2021 Mikel Olasagasti Uranga <mikel@olasagasti.info> - 2.4.0-2
- Add sources

* 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
## END: Generated by rpmautospec