Skip to content

Commit 8a8828d

Browse files
authored
Merge pull request #90 from progit/rework_files
Rework files
2 parents add9929 + 5b52f06 commit 8a8828d

File tree

303 files changed

+1843
-1560
lines changed

Some content is hidden

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

303 files changed

+1843
-1560
lines changed

.gitignore

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

.travis.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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_glob: true
14+
file:
15+
- progit*.epub
16+
- progit*.mobi
17+
- progit*.pdf
18+
skip_cleanup: true
19+
on:
20+
tags: true
21+
api-key: $GITHUB_API_TOKEN
22+
branches:
23+
only:
24+
- master
25+
- /^2\.1(\.\d+)+$/
26+
27+
addons:
28+
apt:
29+
packages:
30+
- epubcheck
31+
notifications:
32+
email:
33+
on_success: never
34+
on_failure: always
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,18 +16,18 @@ Now we'll take a look at some of the other kinds of environments where Git can b
1516
Git은 CLI말고 다른 도구로도 사용할 수 있다. CLI는 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

2425

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

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

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

3132
//////////////////////////
3233
=== 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을 지원하는 애플리케이션을 만들 때는 세 가지 방법의 하나를 선택할 수 있다. 쉘 명령어를 실행시키거나 Libgit2를 사용하거나 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: 241 additions & 240 deletions
Large diffs are not rendered by default.

Gemfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
source 'https://rubygems.org'
22

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

66
gem 'json'
77
gem 'awesome_print'
88

9-
gem 'asciidoctor-epub3', '1.5.0.alpha.6'
10-
gem 'asciidoctor-pdf', '1.5.0.alpha.11'
11-
gem 'asciidoctor-pdf-cjk-kai_gen_gothic', '0.1.1'
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'
1213

1314
gem 'coderay'
1415
gem 'pygments.rb'
1516
gem 'thread_safe'
16-
gem 'epubcheck'
17+
gem 'epubcheck-ruby'
1718
gem 'kindlegen'
19+
20+
gem 'octokit'
21+
gem 'github_changelog_generator', github: 'Furtif/github-changelog-generator'

README.asc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
image::https://travis-ci.org/progit/progit2-ko.svg?branch=master[]
12
= Pro Git, 2판
23

34
짜잔, Pro Git 책의 2판입니다.

Rakefile

Lines changed: 219 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,233 @@
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+
require 'github_changelog_generator'
4+
5+
def exec_or_raise(command)
6+
puts `#{command}`
7+
if (! $?.success?)
8+
raise "'#{command}' failed"
89
end
10+
end
11+
12+
module GitHubChangelogGenerator
13+
14+
#OPTIONS = %w[ user project token date_format output
15+
# bug_prefix enhancement_prefix issue_prefix
16+
# header merge_prefix issues
17+
# add_issues_wo_labels add_pr_wo_labels
18+
# pulls filter_issues_by_milestone author
19+
# unreleased_only unreleased unreleased_label
20+
# compare_link include_labels exclude_labels
21+
# bug_labels enhancement_labels
22+
# between_tags exclude_tags exclude_tags_regex since_tag max_issues
23+
# github_site github_endpoint simple_list
24+
# future_release release_branch verbose release_url
25+
# base configure_sections add_sections]
26+
27+
def get_log(&task_block)
28+
options = Parser.default_options
29+
yield(options) if task_block
30+
31+
options[:user],options[:project] = ENV['TRAVIS_REPO_SLUG'].split('/')
32+
options[:token] = ENV['GITHUB_API_TOKEN']
33+
options[:unreleased] = false
934

35+
generator = Generator.new options
36+
generator.compound_changelog
37+
end
38+
39+
module_function :get_log
40+
end
41+
42+
namespace :book do
1043
desc 'build basic book formats'
11-
task :build => :prebuild do
44+
task :build do
45+
46+
puts "Generating contributors list"
47+
exec_or_raise("git shortlog -s --all| grep -v -E '(Straub|Chacon)' | cut -f 2- | column -c 120 > book/contributors.txt")
48+
49+
# detect if the deployment is using glob
50+
travis = File.read(".travis.yml")
51+
version_string = ENV['TRAVIS_TAG'] || '0'
52+
if travis.match(/file_glob/)
53+
progit_v = "progit_v#{version_string}"
54+
else
55+
progit_v = "progit"
56+
end
57+
text = File.read('progit.asc')
58+
new_contents = text.gsub("$$VERSION$$", version_string).gsub("$$DATE$$", Time.now.strftime("%Y-%m-%d"))
59+
File.open("#{progit_v}.asc", "w") {|file| file.puts new_contents }
60+
1261
puts "Converting to HTML..."
13-
`bundle exec asciidoctor progit.asc`
14-
puts " -- HTML output at progit.html"
62+
exec_or_raise("bundle exec asciidoctor #{progit_v}.asc")
63+
puts " -- HTML output at #{progit_v}.html"
1564

1665
puts "Converting to EPub..."
17-
`bundle exec asciidoctor-epub3 progit.asc`
18-
puts " -- Epub output at progit.epub"
66+
exec_or_raise("bundle exec asciidoctor-epub3 #{progit_v}.asc")
67+
puts " -- Epub output at #{progit_v}.epub"
68+
69+
exec_or_raise("epubcheck #{progit_v}.epub")
1970

2071
puts "Converting to Mobi (kf8)..."
21-
`bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc`
22-
puts " -- Mobi output at progit.mobi"
72+
exec_or_raise("bundle exec asciidoctor-epub3 -a ebook-format=kf8 #{progit_v}.asc")
73+
# remove the fake epub that would shadow the really one
74+
exec_or_raise("rm progit*kf8.epub")
75+
puts " -- Mobi output at #{progit_v}.mobi"
2376

77+
repo = ENV['TRAVIS_REPO_SLUG']
2478
puts "Converting to PDF... (this one takes a while)"
25-
`bundle exec asciidoctor-pdf -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicKR progit.asc 2>/dev/null`
26-
puts " -- PDF output at progit.pdf"
79+
# exec_or_raise("asciidoctor-pdf-cjk-kai_gen_gothic-install")
80+
exec_or_raise("bundle exec asciidoctor-pdf -r asciidoctor-pdf-cjk -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicKR #{progit_v}.asc")
81+
puts " -- PDF output at #{progit_v}.pdf"
82+
end
83+
84+
desc 'tag the repo with the latest version'
85+
task :tag do
86+
api_token = ENV['GITHUB_API_TOKEN']
87+
if ((api_token) && (ENV['TRAVIS_PULL_REQUEST'] == 'false'))
88+
repo = ENV['TRAVIS_REPO_SLUG']
89+
@octokit = Octokit::Client.new(:access_token => api_token)
90+
begin
91+
last_version=@octokit.latest_release(repo).tag_name
92+
rescue
93+
last_version="2.1.-1"
94+
end
95+
new_patchlevel= last_version.split('.')[-1].to_i + 1
96+
new_version="2.1.#{new_patchlevel}"
97+
if (ENV['TRAVIS_BRANCH']=='master')
98+
obj = @octokit.create_tag(repo, new_version, "Version " + new_version,
99+
ENV['TRAVIS_COMMIT'], 'commit',
100+
'Automatic build', '[email protected]',
101+
Time.now.utc.iso8601)
102+
@octokit.create_ref(repo, "tags/#{new_version}", obj.sha)
103+
p "Created tag #{last_version}"
104+
elsif (ENV['TRAVIS_TAG'])
105+
version = ENV['TRAVIS_TAG']
106+
changelog = GitHubChangelogGenerator.get_log do |config|
107+
config[:since_tag] = last_version
108+
end
109+
credit_line = "*This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
110+
changelog.gsub!(credit_line, "")
111+
@octokit.create_release(repo, new_version, {:name => "v#{new_version}", :body => changelog})
112+
p "Created release #{new_version}"
113+
else
114+
p 'This only runs on a commit to master'
115+
end
116+
else
117+
p 'No interaction with GitHub'
118+
end
119+
end
120+
121+
desc 'convert book to asciidoctor compatibility'
122+
task:convert do
123+
`cp -aR ../progit2/images .`
124+
`sed -i -e 's!/images/!!' .gitignore`
125+
`git add images`
126+
`git rm -r book/*/images`
127+
128+
chapters = [
129+
["01", "introduction" ],
130+
["02", "git-basics" ],
131+
["03", "git-branching" ],
132+
["04", "git-server" ],
133+
["05", "distributed-git" ],
134+
["06", "github" ],
135+
["07", "git-tools" ],
136+
["08", "customizing-git" ],
137+
["09", "git-and-other-scms" ],
138+
["10", "git-internals" ],
139+
["A", "git-in-other-environments" ],
140+
["B", "embedding-git" ],
141+
["C", "git-commands" ]
142+
]
143+
144+
crossrefs = {}
145+
chapters.each { | num, title |
146+
if num =~ /[ABC]/
147+
chap = "#{num}-#{title}"
148+
else
149+
chap = "ch#{num}-#{title}"
150+
end
151+
Dir[File.join ["book","#{num}-#{title}" , "sections","*.asc"]].map { |filename|
152+
File.read(filename).scan(/\[\[(.*?)\]\]/)
153+
}.flatten.each { |ref|
154+
crossrefs[ref] = "#{chap}"
155+
}
156+
}
157+
158+
headrefs = {}
159+
chapters.each { | num, title |
160+
if num =~ /[ABC]/
161+
chap = "#{num}-#{title}"
162+
else
163+
chap = "ch#{num}-#{title}"
164+
end
165+
Dir[File.join ["book","#{num}-#{title}", "*.asc"]].map { |filename|
166+
File.read(filename).scan(/\[\[([_a-z0-9]*?)\]\]/)
167+
}.flatten.each { |ref|
168+
headrefs[ref] = "#{chap}"
169+
}
170+
}
171+
172+
# transform all internal cross refs
173+
chapters.each { | num, title |
174+
if num =~ /[ABC]/
175+
chap = "#{num}-#{title}"
176+
else
177+
chap = "ch#{num}-#{title}"
178+
end
179+
files = Dir[File.join ["book","#{num}-#{title}" , "sections","*.asc"]] +
180+
Dir[File.join ["book","#{num}-#{title}" ,"1-*.asc"]]
181+
p files
182+
files.each { |filename|
183+
content = File.read(filename)
184+
new_contents = content.gsub(/\[\[([_a-z0-9]*?)\]\]/, '[[r\1]]').gsub(
185+
"&rarr;", "→").gsub(/<<([_a-z0-9]*?)>>/) { |match|
186+
ch = crossrefs[$1]
187+
h = headrefs[$1]
188+
# p " #{match} -> #{ch}, #{h}"
189+
if ch
190+
# if local do not add the file
191+
if ch==chap
192+
"<<r#{$1}>>"
193+
else
194+
"<<#{ch}#r#{$1}>>"
195+
end
196+
elsif h
197+
if h==chap
198+
"<<#{chap}>>"
199+
else
200+
"<<#{h}##{h}>>"
201+
end
202+
else
203+
p "could not match xref #{$1}"
204+
"<<#{$1}>>"
205+
end
206+
}
207+
File.open(filename, "w") {|file| file.puts new_contents }
208+
}
209+
}
210+
211+
chapters.each { | num, title |
212+
if num =~ /[ABC]/
213+
chap = "#{num}-#{title}"
214+
else
215+
chap = "ch#{num}-#{title}"
216+
end
217+
Dir[File.join ["book","#{num}-#{title}" ,"1*.asc"]].map { |filename|
218+
content = File.read (filename)
219+
new_contents = content.gsub(/include::(.*?)asc/) {|match|
220+
"include::book/#{num}-#{title}/#{$1}asc"}
221+
`git rm -f #{filename}`
222+
File.open("#{chap}.asc", "w") {|file|
223+
file.puts "[##{chap}]\n"
224+
file.puts new_contents }
225+
`git add "#{chap}.asc"`
226+
}
227+
}
27228
end
28229
end
29230

231+
232+
30233
task :default => "book:build"

0 commit comments

Comments
 (0)