%global provider github
%global provider_tld com
%global project github
%global repo hub
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
# https://fedoraproject.org/wiki/Packaging:SourceURL#Github
# For a number of reasons (immutability, availability, uniqueness), you must
# use the full commit revision hash when referring to the sources.
%global commit 7988c4b6b18b0fba0a1483e972cc45bad56e43ad
%global shortcommit %(c=%{commit}; echo ${c:0:7})
# Tests cannot run in mock buildroot currently
# It's recommended to run them locally by switching this value
# before pushing to Koji
%global run_tests 0
Summary: A command-line wrapper for git with github shortcuts
Name: hub
Version: 2.2.5
Release: 3%{?dist}
Group: Development/Languages
License: MIT
URL: http://hub.github.com/
# https://fedoraproject.org/wiki/Packaging:SourceURL#Github
# Keep in mind that github tarballs are generated on-demand, so their
# modification dates will vary and cause checksum tests to fail. Reviewers will
# need to use diff -r to verify the tarballs.
Source0: https://%{provider_prefix}/archive/%{commit}/%{repo}-%{version}-%{shortcommit}.tar.gz
ExclusiveArch: %{go_arches}
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
BuildRequires: git-core
BuildRequires: golang(gopkg.in/yaml.v1)
BuildRequires: golang(github.com/bmizerany/assert)
BuildRequires: golang(github.com/BurntSushi/toml)
BuildRequires: golang(github.com/howeyc/gopass)
BuildRequires: golang(github.com/kballard/go-shellquote)
BuildRequires: golang(github.com/mitchellh/go-homedir)
Requires: git-core
Provides: bundled(golang(github.com/inconshreveable/go-update))
Provides: bundled(golang(github.com/mattn/go-colorable))
Provides: bundled(golang(github.com/mattn/go-isatty))
Provides: bundled(golang(github.com/octokit/go-octokit))
Provides: bundled(golang(github.com/ogier/pflag))
%description
hub is a command line tool that wraps `git` in order to extend it with extra
features and commands that make working with GitHub easier.
$ hub clone rtomayko/tilt
# expands to:
$ git clone git://github.com/rtomayko/tilt.git
%prep
%setup -qn %{name}-%{commit}
rm -rf vendor/gopkg.in/yaml.v1 \
vendor/github.com/bmizerany/assert \
vendor/github.com/BurntSushi/toml \
vendor/github.com/howeyc/gopass \
vendor/github.com/kballard/go-shellquote \
vendor/github.com/mitchellh/go-homedir
%build
mkdir -p src/%{provider}.%{provider_tld}/%{project}/
ln -s ../../../ src/%{provider}.%{provider_tld}/%{project}/%{repo}
export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath}
%gobuild -o bin/%{name} %{import_path}
%install
# /bin/hub
install -d -p %{buildroot}%{_bindir}
install -p -m 755 bin/%{name} %{buildroot}%{_bindir}
# Documentation
install -d -m 755 %{buildroot}%{_mandir}/man1/
cp -p man/hub.1 %{buildroot}%{_mandir}/man1/.
# Bash-completion
install -d -m 755 %{buildroot}%{_sysconfdir}/bash_completion.d/
cp -p etc/hub.bash_completion.sh %{buildroot}%{_sysconfdir}/bash_completion.d/.
# ZSH-completion
install -d -m 755 %{buildroot}%{_datarootdir}/zsh/site-functions/
cp -p etc/hub.zsh_completion %{buildroot}%{_datarootdir}/zsh/site-functions/_hub
%check
%if 0%{run_tests}
# Tests are currently nonfunctional in mock
# All calls to 'git' are failing to find a valid repo, but
# they work when run outside of mock.
export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath}
find . -maxdepth 2 -name '*.go' '!' -name '*_test.go' | \
cut -d/ -f2 | sort -u | grep -v '.go$' | sed 's!^!github.com/github/hub/!' | \
xargs go test -v
%endif
%pretrans -p <lua>
-- hub versions 2.2.5-1 and 2.2.5-2 accidentally included
-- a directory instead of the actual zsh completion script
-- so we need to move it out of the way and install the
-- correct script. This should be removable in Fedora 27.
-- Script taken from
-- https://fedoraproject.org/w/index.php?title=Packaging:Directory_Replacement&oldid=372506#Scriptlet_to_replace_a_directory
path = "/usr/share/zsh/site-functions/_hub"
st = posix.stat(path)
if st and st.type == "directory" then
status = os.rename(path, path .. ".rpmmoved")
if not status then
suffix = 0
while not status do
suffix = suffix + 1
status = os.rename(path .. ".rpmmoved", path .. ".rpmmoved." .. suffix)
end
os.rename(path, path .. ".rpmmoved")
end
end
%files
%license LICENSE
%doc README.md CONTRIBUTING.md
%doc man/hub.1.html man/hub.1.ronn
%{_bindir}/hub
%{_mandir}/man1/hub.1.gz
%{_sysconfdir}/bash_completion.d/
%{_datarootdir}/zsh/site-functions/_hub
%ghost %{_datarootdir}/zsh/site-functions/_hub.rpmmoved
%changelog
* Wed Sep 28 2016 Stephen Gallagher <sgallagh@redhat.com> - 2.2.5-3
- Really fix location of ZSH completion script
* Tue Sep 13 2016 Stephen Gallagher <sgallagh@redhat.com> - 2.2.5-2
- Fix location of ZSH completion script
* Wed Aug 31 2016 Stephen Gallagher <sgallagh@redhat.com> - 2.2.5-1
- Update to new (and latest) major release of hub
- Include ZSH completion script
* Wed Feb 03 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.12.4-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Fri Sep 11 2015 Ralph Bean <rbean@redhat.com> - 1.12.4-5
- Adjust ownership of bash_completion file/dir.
* Fri Sep 11 2015 Ralph Bean <rbean@redhat.com> - 1.12.4-4
- Ship bash completion file.
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.12.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Wed May 27 2015 Ralph Bean <rbean@redhat.com> - 1.12.4-2
- Require ruby (for ruby-mri. jruby and hub don't get along.)
https://bugzilla.redhat.com/show_bug.cgi?id=1225254
* Wed Apr 22 2015 Ralph Bean <rbean@redhat.com> - 1.12.4-1
- New version
- Stop building with rdoc for now because its being so squirrely.
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.12.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Wed May 28 2014 Ralph Bean <rbean@redhat.com> - 1.12.1-1
- Latest upstream.
* Thu May 22 2014 Ralph Bean <rbean@redhat.com> - 1.12.0-4
- Add -doc subpackage with rdoc product.
- Add check section, but left it commented out due to dep issues.
- Remove spurious man files.
- Remove weirdly nested docs from rdoc.
* Wed Apr 02 2014 Ralph Bean <rbean@redhat.com> - 1.12.0-3
- Update Source0 URL to use the github guidelines.
- Replace weird %%prep %%setup stuff with something more familiar.
* Wed Apr 02 2014 Ralph Bean <rbean@redhat.com> - 1.12.0-2
- Remove version from the doc directory.
- Replace install macro with just "install".
* Mon Mar 31 2014 Ralph Bean <rbean@redhat.com> - 1.12.0-1
- Initial packaging for Fedora