tool/git-refresh

* tool/git-refresh: tool to clone or update git working directory.

* Makefile.in: use git-refresh.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-03-30 06:44:27 +00:00
parent a84259659e
commit c73db5c172
2 changed files with 56 additions and 57 deletions

View File

@ -473,76 +473,32 @@ update-download:: update-config_files
after-update:: common-srcs after-update:: common-srcs
update-mspec: update-mspec:
@$(CHDIR) $(srcdir); \ $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/spec $(Q1:0=-q) \
if [ -d spec/mspec ]; then \ $(MSPEC_GIT_URL) mspec $(GIT_OPTS)
echo updating mspec ...; \
$(Q1:0=:) set -x; \
cd spec/mspec && \
exec git pull; \
else \
echo retrieving mspec ...; \
$(Q1:0=:) set -x; \
exec git clone $(MSPEC_GIT_URL) spec/mspec; \
fi
$(Q)$(CHDIR) $(srcdir)/spec/mspec && exec git --no-pager log -1 --oneline $(Q)$(CHDIR) $(srcdir)/spec/mspec && exec git --no-pager log -1 --oneline
update-rubyspec: update-mspec update-rubyspec: update-mspec
@$(CHDIR) $(srcdir); \ $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/spec $(Q1:0=-q) \
if [ -d spec/rubyspec ]; then \ $(RUBYSPEC_GIT_URL) rubyspec $(GIT_OPTS)
echo updating rubyspec ...; \
$(Q1:0=:) set -x; \
cd spec/rubyspec && \
exec git pull; \
else \
echo retrieving rubyspec ...; \
$(Q1:0=:) set -x; \
exec git clone $(RUBYSPEC_GIT_URL) spec/rubyspec; \
fi
$(Q)$(CHDIR) $(srcdir)/spec/rubyspec && exec git --no-pager log -1 --oneline $(Q)$(CHDIR) $(srcdir)/spec/rubyspec && exec git --no-pager log -1 --oneline
test-rubyspec-precheck: test-rubyspec-precheck:
@if [ ! -d $(srcdir)/spec/rubyspec ]; then echo No rubyspec here. make update-rubyspec first.; exit 1; fi @if [ ! -d $(srcdir)/spec/rubyspec ]; then echo No rubyspec here. make update-rubyspec first.; exit 1; fi
update-doclie: update-doclie:
@$(CHDIR) $(srcdir); \ $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
if [ -d coverage/doclie ]; then \ --branch $(DOCLIE_GIT_REF) \
echo updating doclie ...; \ $(DOCLIE_GIT_URL) doclie $(GIT_OPTS)
$(Q1:0=:) set -x; \
cd coverage/doclie && \
git fetch && \
exec git checkout $(DOCLIE_GIT_REF); \
else \
echo retrieving doclie ...; \
$(Q1:0=:) set -x; \
exec git clone --branch $(DOCLIE_GIT_REF) $(DOCLIE_GIT_URL) coverage/doclie; \
fi
update-simplecov-html: update-simplecov-html:
@$(CHDIR) $(srcdir); \ $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
if [ -d coverage/simplecov-html ]; then \ --branch $(SIMPLECOV_HTML_GIT_REF) \
echo updating simplecov-html ...; \ $(SIMPLECOV_HTML_GIT_URL) simplecov-html $(GIT_OPTS)
$(Q1:0=:) set -x; \
cd coverage/simplecov-html && \
git fetch && \
exec git checkout $(SIMPLECOV_HTML_GIT_REF); \
else \
echo retrieving simplecov-html ...; \
exec git clone --branch $(SIMPLECOV_HTML_GIT_REF) $(SIMPLECOV_HTML_GIT_URL) coverage/simplecov-html; \
fi
update-simplecov: update-simplecov:
@$(CHDIR) $(srcdir); \ $(Q) $(srcdir)/tool/git-refresh -C $(srcdir)/coverage $(Q1:0=-q) \
if [ -d coverage/simplecov ]; then \ --branch $(SIMPLECOV_GIT_REF) \
echo updating simplecov ...; \ $(SIMPLECOV_GIT_URL) simplecov-html $(GIT_OPTS)
$(Q1:0=:) set -x; \
cd coverage/simplecov && \
git fetch && \
exec git checkout $(SIMPLECOV_GIT_REF); \
else \
echo retrieving simplecov ...; \
$(Q1:0=:) set -x; \
exec git clone --branch $(SIMPLECOV_GIT_REF) $(SIMPLECOV_GIT_URL) coverage/simplecov; \
fi
update-coverage: update-simplecov update-simplecov-html update-doclie update-coverage: update-simplecov update-simplecov-html update-doclie

43
tool/git-refresh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/sh
set -e
quiet=
branch=
OPT_SPEC="\
${0##*/} [options] URL dir [options]
--
C=directory Change directory
q,quiet Quiet
b,branch=branch Checkout branch
"
rev="$(echo "$OPT_SPEC" | git rev-parse --parseopt -- "$@")"
status=$?
eval "$rev"
[ $status = 0 ] || exit $status
until [ $# = 0 ]; do
case "$1" in
--) shift; break;;
-C) shift; cd "$1";;
-q) quiet=1;;
-b) shift; branch="$1";;
-*) echo "unknown option: $1" 1>&2; exit 1;;
*) break;;
esac
shift
done
url="$1"
dir="$2"
shift 2
if [ -d "$dir" ]; then
echo updating "${dir#*/}" ...
[ $quiet ] || set -x
cd "$dir"
git fetch "$@"
exec git checkout ${branch:+"$branch"} "$@"
else
echo retrieving "${dir#*/}" ...
[ $quiet ] || set -x
exec git clone "$url" "$dir" "$@"
fi