Skip to content

Commit 63dfdd1

Browse files
authored
Merge pull request #102 from progit/rework_files
Rework files
2 parents 271146b + f3670b4 commit 63dfdd1

File tree

295 files changed

+1103
-970
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+1103
-970
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ progit.pdfmarks
88
progit.epub
99
progit-kf8.epub
1010
progit.mobi
11-
/images/
11+

.travis.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
language: ruby
2+
sudo: false
3+
git:
4+
depth: false
5+
cache: bundler
6+
before_install:
7+
- wget https://raw.githubusercontent.com/progit/progit2-pub/master/bootstrap.sh
8+
- sh bootstrap.sh
9+
script: bundle exec rake book:build
10+
after_success: bundle exec rake book:tag
11+
deploy:
12+
provider: releases
13+
file:
14+
- progit.epub
15+
- progit.mobi
16+
- progit.pdf
17+
skip_cleanup: true
18+
on:
19+
tags: true
20+
api-key: $GITHUB_API_TOKEN
21+
branches:
22+
only:
23+
- master
24+
- /^2\.1(\.\d+)+$/
25+
26+
addons:
27+
apt:
28+
packages:
29+
- epubcheck
30+
notifications:
31+
email:
32+
on_success: never
33+
on_failure: always

book/A-git-in-other-environments/1-git-other-environments.asc renamed to A-git-in-other-environments.asc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[#A-git-in-other-environments]
12
[appendix]
23
//////////////////////////
34
== Git in Other Environments
@@ -15,17 +16,17 @@ Now we'll take a look at some of the other kinds of environments where Git can b
1516
しかし、話はそこで終わりません。Gitは通常、より大きなエコシステムの一部として使用されます。端末からの利用が常に最適解というわけではありません。
1617
ここでは、端末以外でGitを活用できる環境の例や、そこで他の(あるいは、あなたの)アプリケーションがどのようにGitと協調動作するかを見ていきます。
1718

18-
include::sections/guis.asc[]
19+
include::book/A-git-in-other-environments/sections/guis.asc[]
1920

20-
include::sections/visualstudio.asc[]
21+
include::book/A-git-in-other-environments/sections/visualstudio.asc[]
2122

22-
include::sections/eclipse.asc[]
23+
include::book/A-git-in-other-environments/sections/eclipse.asc[]
2324

24-
include::sections/bash.asc[]
25+
include::book/A-git-in-other-environments/sections/bash.asc[]
2526

26-
include::sections/zsh.asc[]
27+
include::book/A-git-in-other-environments/sections/zsh.asc[]
2728

28-
include::sections/powershell.asc[]
29+
include::book/A-git-in-other-environments/sections/powershell.asc[]
2930

3031
//////////////////////////
3132
=== Summary

book/B-embedding-git/1-embedding-git.asc renamed to B-embedding-git.asc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[#B-embedding-git]
12
[appendix]
23
//////////////////////////
34
== Embedding Git in your Applications
@@ -16,8 +17,8 @@ If you need to integrate Git with your application, you have essentially three c
1617
//////////////////////////
1718
Gitをアプリケーションに統合する場合、やり方は大きく分けて3種類あります。1つ目はシェルのプロセスを生成してGitのコマンドラインツールを使う方法、2つ目はLibgit2を使う方法、3つ目はJGitを使う方法です。
1819

19-
include::sections/command-line.asc[]
20+
include::book/B-embedding-git/sections/command-line.asc[]
2021

21-
include::sections/libgit2.asc[]
22+
include::book/B-embedding-git/sections/libgit2.asc[]
2223

23-
include::sections/jgit.asc[]
24+
include::book/B-embedding-git/sections/jgit.asc[]

book/C-git-commands/1-git-commands.asc renamed to C-git-commands.asc

Lines changed: 232 additions & 231 deletions
Large diffs are not rendered by default.

Gemfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
source 'https://rubygems.org'
22

33
gem 'rake'
4-
gem 'asciidoctor', '1.5.0'
4+
gem 'asciidoctor', '1.5.6.1'
55

66
gem 'json'
77
gem 'awesome_print'
88

9-
gem 'asciidoctor-epub3', '1.0.0.alpha.2'
10-
gem 'asciidoctor-pdf', '1.5.0.alpha.5'
9+
gem 'asciidoctor-epub3', :git => 'https://github.com/asciidoctor/asciidoctor-epub3'
10+
gem 'asciidoctor-pdf', '1.5.0.alpha.16'
11+
gem 'asciidoctor-pdf-cjk', '~> 0.1.3'
12+
gem 'asciidoctor-pdf-cjk-kai_gen_gothic', '~> 0.1.1'
1113

1214
gem 'coderay'
1315
gem 'pygments.rb'
1416
gem 'thread_safe'
1517
gem 'epubcheck'
1618
gem 'kindlegen'
19+
20+
gem 'octokit'

Gemfile.lock

Lines changed: 0 additions & 74 deletions
This file was deleted.

Rakefile

Lines changed: 155 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,172 @@
1-
namespace :book do
2-
desc 'prepare build'
3-
task :prebuild do
4-
Dir.mkdir 'images' unless Dir.exists? 'images'
5-
Dir.glob("book/*/images/*").each do |image|
6-
FileUtils.copy(image, "images/" + File.basename(image))
7-
end
1+
# coding: utf-8
2+
require 'octokit'
3+
4+
def exec_or_raise(command)
5+
puts `#{command}`
6+
if (! $?.success?)
7+
raise "'#{command}' failed"
88
end
9+
end
910

11+
namespace :book do
1012
desc 'build basic book formats'
11-
task :build => :prebuild do
13+
task :build do
14+
15+
puts "Generating contributors list"
16+
exec_or_raise("git shortlog -s --all| grep -v -E '(Straub|Chacon)' | cut -f 2- | column -c 120 > book/contributors.txt")
17+
1218
puts "Converting to HTML..."
13-
`bundle exec asciidoctor progit.asc`
19+
exec_or_raise("bundle exec asciidoctor progit.asc")
1420
puts " -- HTML output at progit.html"
1521

1622
puts "Converting to EPub..."
17-
`bundle exec asciidoctor-epub3 progit.asc`
23+
exec_or_raise("bundle exec asciidoctor-epub3 progit.asc")
1824
puts " -- Epub output at progit.epub"
1925

26+
exec_or_raise("epubcheck progit.epub")
27+
2028
puts "Converting to Mobi (kf8)..."
21-
`bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc`
29+
exec_or_raise("bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc")
2230
puts " -- Mobi output at progit.mobi"
2331

32+
repo = ENV['TRAVIS_REPO_SLUG']
2433
puts "Converting to PDF... (this one takes a while)"
25-
`bundle exec asciidoctor-pdf progit.asc 2>/dev/null`
26-
puts " -- PDF output at progit.pdf"
34+
exec_or_raise("asciidoctor-pdf-cjk-kai_gen_gothic-install")
35+
exec_or_raise("bundle exec asciidoctor-pdf -r asciidoctor-pdf-cjk -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicJP progit.asc")
36+
puts " -- PDF output at progit.pdf"
37+
end
38+
39+
desc 'tag the repo with the latest version'
40+
task :tag do
41+
api_token = ENV['GITHUB_API_TOKEN']
42+
if (api_token && (ENV['TRAVIS_PULL_REQUEST'] == 'false') && (ENV['TRAVIS_BRANCH']=='master'))
43+
repo = ENV['TRAVIS_REPO_SLUG']
44+
@octokit = Octokit::Client.new(:access_token => api_token)
45+
begin
46+
last_version=@octokit.latest_release(repo).tag_name
47+
rescue
48+
last_version="2.1.-1"
49+
end
50+
new_patchlevel= last_version.split('.')[-1].to_i + 1
51+
new_version="2.1.#{new_patchlevel}"
52+
obj = @octokit.create_tag(repo, new_version, "Version " + new_version, ENV['TRAVIS_COMMIT'],
53+
'commit',
54+
'Automatic build', '[email protected]',
55+
Time.now.utc.iso8601)
56+
@octokit.create_ref(repo, "tags/#{new_version}", obj.sha)
57+
p "Created tag #{new_version}"
58+
else
59+
p 'This only runs on a commit to master'
60+
end
61+
end
62+
63+
desc 'convert book to asciidoctor compatibility'
64+
task:convert do
65+
`cp -aR ../progit2/images .`
66+
`sed -i -e 's!/images/!!' .gitignore`
67+
`git add images`
68+
`git rm -r book/*/images`
69+
70+
chapters = [
71+
["01", "introduction" ],
72+
["02", "git-basics" ],
73+
["03", "git-branching" ],
74+
["04", "git-server" ],
75+
["05", "distributed-git" ],
76+
["06", "github" ],
77+
["07", "git-tools" ],
78+
["08", "customizing-git" ],
79+
["09", "git-and-other-scms" ],
80+
["10", "git-internals" ],
81+
["A", "git-in-other-environments" ],
82+
["B", "embedding-git" ],
83+
["C", "git-commands" ]
84+
]
85+
86+
crossrefs = {}
87+
chapters.each { | num, title |
88+
if num =~ /[ABC]/
89+
chap = "#{num}-#{title}"
90+
else
91+
chap = "ch#{num}-#{title}"
92+
end
93+
Dir[File.join ["book","#{num}-#{title}" , "sections","*.asc"]].map { |filename|
94+
File.read(filename).scan(/\[\[(.*?)\]\]/)
95+
}.flatten.each { |ref|
96+
crossrefs[ref] = "#{chap}"
97+
}
98+
}
99+
100+
headrefs = {}
101+
chapters.each { | num, title |
102+
if num =~ /[ABC]/
103+
chap = "#{num}-#{title}"
104+
else
105+
chap = "ch#{num}-#{title}"
106+
end
107+
Dir[File.join ["book","#{num}-#{title}", "*.asc"]].map { |filename|
108+
File.read(filename).scan(/\[\[(.*?)\]\]/)
109+
}.flatten.each { |ref|
110+
headrefs[ref] = "#{chap}"
111+
}
112+
}
113+
114+
# transform all internal cross refs
115+
chapters.each { | num, title |
116+
if num =~ /[ABC]/
117+
chap = "#{num}-#{title}"
118+
else
119+
chap = "ch#{num}-#{title}"
120+
end
121+
files = Dir[File.join ["book","#{num}-#{title}" , "sections","*.asc"]] +
122+
Dir[File.join ["book","#{num}-#{title}" ,"1-*.asc"]]
123+
p files
124+
files.each { |filename|
125+
content = File.read(filename)
126+
new_contents = content.gsub(/\[\[(.*?)\]\]/, '[[r\1]]').gsub(
127+
"&rarr;", "→").gsub(/<<(.*?)>>/) { |match|
128+
ch = crossrefs[$1]
129+
h = headrefs[$1]
130+
# p " #{match} -> #{ch}, #{h}"
131+
if ch
132+
# if local do not add the file
133+
if ch==chap
134+
"<<r#{$1}>>"
135+
else
136+
"<<#{ch}#r#{$1}>>"
137+
end
138+
elsif h
139+
if h==chap
140+
"<<#{chap}>>"
141+
else
142+
"<<#{h}##{h}>>"
143+
end
144+
end
145+
}
146+
File.open(filename, "w") {|file| file.puts new_contents }
147+
}
148+
}
149+
150+
chapters.each { | num, title |
151+
if num =~ /[ABC]/
152+
chap = "#{num}-#{title}"
153+
else
154+
chap = "ch#{num}-#{title}"
155+
end
156+
Dir[File.join ["book","#{num}-#{title}" ,"1*.asc"]].map { |filename|
157+
content = File.read (filename)
158+
new_contents = content.gsub(/include::(.*?)asc/) {|match|
159+
"include::book/#{num}-#{title}/#{$1}asc"}
160+
`git rm -f #{filename}`
161+
File.open("#{chap}.asc", "w") {|file|
162+
file.puts "[##{chap}]\n"
163+
file.puts new_contents }
164+
`git add "#{chap}.asc"`
165+
}
166+
}
27167
end
28168
end
29169

170+
171+
30172
task :default => "book:build"

0 commit comments

Comments
 (0)