## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 4;
    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.0
#
# This specfile is licensed under:
# SPDX-License-Identifier: MIT
# License text: https://spdx.org/licenses/MIT.html
# SPDX-FileCopyrightText: 2022 Maxwell G <gotmax@e.email>
# SPDX-FileCopyrightText: Fedora Project Authors

%bcond_without check

# https://git.sr.ht/~emersion/hut
%global goipath         git.sr.ht/~emersion/hut
%global topdir          hut-%{version}
Version:                0.2.0

%gometa -f

%global goname          hut
%global common_description %{expand:
hut is a CLI tool for interacting with Sourcehut instances. It supports
git.sr.ht as well as self-hosted Sourcehut instances.}

%global golicenses      LICENSE
%global godocs          README.md

Name:           %{goname}
Release:        %autorelease
Summary:        A CLI tool for Sourcehut

License:        AGPL-3.0-only
URL:            %{gourl}
# The maintainer provides a signed archive, so use that instead of the Sourcehut
# generated one.
# https://docs.fedoraproject.org/en-US/packaging-guidelines/#_source_file_verification
%dnl Source:         %{gourl}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
%global signed_source %{gourl}/refs/download/v%{version}/hut-%{version}.tar.gz
Source0:        %{signed_source}
Source1:        %{signed_source}.sig
Source2:        https://emersion.fr/.well-known/openpgpkey/hu/dj3498u4hyyarh35rkjfnghbjxug6b19#/emersion.asc

BuildRequires:  scdoc
BuildRequires:  gnupg2

%description %{common_description}

%gopkg

%prep
%gpgverify -d0 -s1 -k2
%goprep
# We use %%gobuild to build the hut binary
sed -i 's|$(GO) build $(GOFLAGS)|true|' Makefile

%generate_buildrequires
%go_generate_buildrequires

%build
# The Makefile expects hut to be in the current directory
%gobuild -o hut %{goipath}
%make_build doc/hut.1 completions

%install
%gopkginstall
%make_install PREFIX=%{_prefix}


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

%files
%license LICENSE
%doc README.md
%{_bindir}/hut
%{_mandir}/man1/hut.1*
%{bash_completions_dir}/hut
%{zsh_completions_dir}/_hut
%{fish_completions_dir}/hut.fish

%gopkgfiles

%changelog
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> 0.2.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Wed Sep 28 2022 Maxwell G <gotmax@e.email> 0.2.0-3
- Define %%_topdir to fix %%goprep on older Fedoras

* Wed Sep 28 2022 Maxwell G <gotmax@e.email> 0.2.0-2
- Don't include the manpage sources in package

* Wed Sep 28 2022 Maxwell G <gotmax@e.email> 0.2.0-1
- Initial import (rhbz#2124025).