提交 54262e66 编写于 作者: M Mislav Marohnić

Makefile galore!

上级 fc9fbd4c
......@@ -5,6 +5,7 @@
vendor/bundle/
man/hub.1
man/hub.1.html
man/hub.1.txt
man/hub-*
tmp/
*.test
......
......@@ -10,7 +10,7 @@ before_install:
language: go
go:
- 1.5.1
script: script/test
script: make test-all
install: script/cached-bundle install --without development --deployment --jobs=3 --retry=3
after_success: script/publish-release
notifications:
......
......@@ -29,27 +29,21 @@ feature is a good idea for hub if it improves some workflow for a GitHub user.
## How to install dependencies and run tests
These instructions assume that _you already have hub installed_ and aliased as
`git` (see "Aliasing").
1. Clone hub:
`git clone github/hub && cd hub`
1. Install necessary development dependencies:
`script/bootstrap`
`git clone https://github.com/github/hub.git && cd hub`
2. Verify that existing tests pass:
`script/test`
`make test-all`
3. Create a topic branch:
`git checkout -b feature`
4. **Make your changes.**
(It helps a lot if you write tests first.)
5. Verify that tests still pass:
`script/test`
5. Verify that the tests still pass.
6. Fork hub on GitHub (adds a remote named "YOUR-USER"):
`git fork`
`make && bin/hub fork`
7. Push to your fork:
`git push <YOUR-USER> HEAD`
`git push -u <YOUR-USER> HEAD`
8. Open a pull request describing your changes:
`git pull-request`
`bin/hub pull-request`
## How to write tests
......
SOURCES = $(shell script/build files)
HELP_CMD = \
man/hub-alias.1 \
man/hub-browse.1 \
man/hub-ci-status.1 \
man/hub-compare.1 \
man/hub-create.1 \
man/hub-fork.1 \
man/hub-pull-request.1 \
HELP_EXT = \
man/hub-am.1 \
man/hub-apply.1 \
man/hub-checkout.1 \
man/hub-cherry-pick.1 \
man/hub-clone.1 \
man/hub-fetch.1 \
man/hub-init.1 \
man/hub-merge.1 \
man/hub-push.1 \
man/hub-remote.1 \
man/hub-submodule.1 \
HELP_ALL = man/hub.1 $(HELP_CMD) $(HELP_EXT)
TEXT_WIDTH = 87
.PHONY: clean test test-all man-pages
all: bin/hub
bin/hub: $(SOURCES)
script/build -o $@
test:
script/build test
test-all: bin/cucumber
script/test
bin/ronn bin/cucumber:
script/bootstrap
man-pages: $(HELP_ALL:=.ronn) $(HELP_ALL) $(HELP_ALL:=.txt)
%.txt: %.ronn
groff -Wall -mtty-char -mandoc -Tutf8 -rLL=$(TEXT_WIDTH)n $< | col -b >$@
%.1: %.1.ronn bin/ronn
bin/ronn --organization=GITHUB --manual="Hub Manual" man/*.ronn
%.1.ronn: bin/hub
bin/hub help $(*F) --plain-text | script/format-ronn $(*F) $@
man/hub.1.ronn:
true
clean:
rm -rf bin/hub
git clean -fdx man/
#!/usr/bin/env bash
# vi:ft=sh:
# Usage: script/build [-o <EXE>]
# script/build test
#
......@@ -40,18 +41,10 @@ find_packages() {
find_source_files | cut -d/ -f2 | sort -u | grep -v '.go$' | sed 's!^!github.com/github/hub/!'
}
count_changed_files() {
printf %d $(find_source_files -newer "$1" | wc -l)
}
up_to_date() {
[ -e "$1" ] && [ "$(count_changed_files "$1")" -eq 0 ]
}
build_hub() {
setup_gopath
mkdir -p "$(dirname "$1")"
up_to_date "$1" || go build -ldflags "-X github.com/github/hub/version.Version=`./script/version`" -o "$1"
go build -ldflags "-X github.com/github/hub/version.Version=`./script/version`" -o "$1"
}
test_hub() {
......@@ -77,7 +70,7 @@ files )
find_source_files
;;
-h | --help )
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
sed -ne '/^#/!q;s/.\{1,2\}//;1,2d;p' < "$0"
exit
;;
* )
......
#!/bin/bash
# Usage: script/man [<COMMAND>]
# Usage: script/format-ronn <COMMAND> [<FILE>]
#
# Generate individual man pages from inline help text of hub commands.
# Transform inline text of hub commands to ronn-format(7).
set -e
extensions="
am
apply
checkout
cherry-pick
clone
fetch
init
merge
push
remote
submodule
"
commands="
alias
browse
ci-status
compare
create
fork
pull-request
"
AWK="$(type -p gawk awk | head -1)"
hub_help() {
bin/hub help "hub-$1" --plain-text | sed $'s/\t/ /g'
}
para() {
"$AWK" -v wants=$2 "
BEGIN { para=1 }
......@@ -74,41 +46,17 @@ format_rest() {
'
}
generate() {
local cmd="$1"
local text="$(hub_help "$cmd")"
[ -n "$text" ] || continue
{ echo "hub-${cmd}(1) -- $(para == 2 <<<"$text" | format_shortdesc)"
echo "==="
echo
echo "## SYNOPSIS"
echo
para == 1 <<<"$text" | format_synopsis
echo
para '>=' 3 <<<"$text" | format_rest
} > "man/hub-${cmd}.1.ronn"
}
man_desc() {
echo " * hub-${1}(1):"
echo " $(hub_help "$1" | para == 2 | format_shortdesc)"
}
script/build
case "$1" in
--desc )
for cmd in $extensions $commands; do
man_desc "$cmd"
echo
done
;;
* )
for cmd in ${1:-$commands $extensions}; do
generate "$cmd"
done
bin/ronn --organization=GITHUB --manual="Hub Manual" man/*.ronn
;;
esac
cmd="${1?}"
file="$2"
text="$(cat - | sed $'s/\t/ /g')"
[ -n "$text" ] || exit 1
[ -z "$file" ] || exec 1<> "$file"
echo "${cmd}(1) -- $(para == 2 <<<"$text" | format_shortdesc)"
echo "==="
echo
echo "## SYNOPSIS"
echo
para == 1 <<<"$text" | format_synopsis
echo
para '>=' 3 <<<"$text" | format_rest
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册