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