Skip to content

Commit

Permalink
Merge pull request #102 from progit/rework_files
Browse files Browse the repository at this point in the history
Rework files
  • Loading branch information
harupong committed Feb 22, 2018
2 parents 271146b + f3670b4 commit 63dfdd1
Show file tree
Hide file tree
Showing 295 changed files with 1,103 additions and 970 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ progit.pdfmarks
progit.epub
progit-kf8.epub
progit.mobi
/images/

33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: ruby
sudo: false
git:
depth: false
cache: bundler
before_install:
- wget https://raw.githubusercontent.com/progit/progit2-pub/master/bootstrap.sh
- sh bootstrap.sh
script: bundle exec rake book:build
after_success: bundle exec rake book:tag
deploy:
provider: releases
file:
- progit.epub
- progit.mobi
- progit.pdf
skip_cleanup: true
on:
tags: true
api-key: $GITHUB_API_TOKEN
branches:
only:
- master
- /^2\.1(\.\d+)+$/

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

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

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

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

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

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

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

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

include::sections/command-line.asc[]
include::book/B-embedding-git/sections/command-line.asc[]

include::sections/libgit2.asc[]
include::book/B-embedding-git/sections/libgit2.asc[]

include::sections/jgit.asc[]
include::book/B-embedding-git/sections/jgit.asc[]
463 changes: 232 additions & 231 deletions book/C-git-commands/1-git-commands.asc → C-git-commands.asc

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
source 'https://rubygems.org'

gem 'rake'
gem 'asciidoctor', '1.5.0'
gem 'asciidoctor', '1.5.6.1'

gem 'json'
gem 'awesome_print'

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

gem 'coderay'
gem 'pygments.rb'
gem 'thread_safe'
gem 'epubcheck'
gem 'kindlegen'

gem 'octokit'
74 changes: 0 additions & 74 deletions Gemfile.lock

This file was deleted.

168 changes: 155 additions & 13 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,172 @@
namespace :book do
desc 'prepare build'
task :prebuild do
Dir.mkdir 'images' unless Dir.exists? 'images'
Dir.glob("book/*/images/*").each do |image|
FileUtils.copy(image, "images/" + File.basename(image))
end
# coding: utf-8
require 'octokit'

def exec_or_raise(command)
puts `#{command}`
if (! $?.success?)
raise "'#{command}' failed"
end
end

namespace :book do
desc 'build basic book formats'
task :build => :prebuild do
task :build do

puts "Generating contributors list"
exec_or_raise("git shortlog -s --all| grep -v -E '(Straub|Chacon)' | cut -f 2- | column -c 120 > book/contributors.txt")

puts "Converting to HTML..."
`bundle exec asciidoctor progit.asc`
exec_or_raise("bundle exec asciidoctor progit.asc")
puts " -- HTML output at progit.html"

puts "Converting to EPub..."
`bundle exec asciidoctor-epub3 progit.asc`
exec_or_raise("bundle exec asciidoctor-epub3 progit.asc")
puts " -- Epub output at progit.epub"

exec_or_raise("epubcheck progit.epub")

puts "Converting to Mobi (kf8)..."
`bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc`
exec_or_raise("bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc")
puts " -- Mobi output at progit.mobi"

repo = ENV['TRAVIS_REPO_SLUG']
puts "Converting to PDF... (this one takes a while)"
`bundle exec asciidoctor-pdf progit.asc 2>/dev/null`
puts " -- PDF output at progit.pdf"
exec_or_raise("asciidoctor-pdf-cjk-kai_gen_gothic-install")
exec_or_raise("bundle exec asciidoctor-pdf -r asciidoctor-pdf-cjk -r asciidoctor-pdf-cjk-kai_gen_gothic -a pdf-style=KaiGenGothicJP progit.asc")
puts " -- PDF output at progit.pdf"
end

desc 'tag the repo with the latest version'
task :tag do
api_token = ENV['GITHUB_API_TOKEN']
if (api_token && (ENV['TRAVIS_PULL_REQUEST'] == 'false') && (ENV['TRAVIS_BRANCH']=='master'))
repo = ENV['TRAVIS_REPO_SLUG']
@octokit = Octokit::Client.new(:access_token => api_token)
begin
last_version=@octokit.latest_release(repo).tag_name
rescue
last_version="2.1.-1"
end
new_patchlevel= last_version.split('.')[-1].to_i + 1
new_version="2.1.#{new_patchlevel}"
obj = @octokit.create_tag(repo, new_version, "Version " + new_version, ENV['TRAVIS_COMMIT'],
'commit',
'Automatic build', 'automatic@no-domain.org',
Time.now.utc.iso8601)
@octokit.create_ref(repo, "tags/#{new_version}", obj.sha)
p "Created tag #{new_version}"
else
p 'This only runs on a commit to master'
end
end

desc 'convert book to asciidoctor compatibility'
task:convert do
`cp -aR ../progit2/images .`
`sed -i -e 's!/images/!!' .gitignore`
`git add images`
`git rm -r book/*/images`

chapters = [
["01", "introduction" ],
["02", "git-basics" ],
["03", "git-branching" ],
["04", "git-server" ],
["05", "distributed-git" ],
["06", "github" ],
["07", "git-tools" ],
["08", "customizing-git" ],
["09", "git-and-other-scms" ],
["10", "git-internals" ],
["A", "git-in-other-environments" ],
["B", "embedding-git" ],
["C", "git-commands" ]
]

crossrefs = {}
chapters.each { | num, title |
if num =~ /[ABC]/
chap = "#{num}-#{title}"
else
chap = "ch#{num}-#{title}"
end
Dir[File.join ["book","#{num}-#{title}" , "sections","*.asc"]].map { |filename|
File.read(filename).scan(/\[\[(.*?)\]\]/)
}.flatten.each { |ref|
crossrefs[ref] = "#{chap}"
}
}

headrefs = {}
chapters.each { | num, title |
if num =~ /[ABC]/
chap = "#{num}-#{title}"
else
chap = "ch#{num}-#{title}"
end
Dir[File.join ["book","#{num}-#{title}", "*.asc"]].map { |filename|
File.read(filename).scan(/\[\[(.*?)\]\]/)
}.flatten.each { |ref|
headrefs[ref] = "#{chap}"
}
}

# transform all internal cross refs
chapters.each { | num, title |
if num =~ /[ABC]/
chap = "#{num}-#{title}"
else
chap = "ch#{num}-#{title}"
end
files = Dir[File.join ["book","#{num}-#{title}" , "sections","*.asc"]] +
Dir[File.join ["book","#{num}-#{title}" ,"1-*.asc"]]
p files
files.each { |filename|
content = File.read(filename)
new_contents = content.gsub(/\[\[(.*?)\]\]/, '[[r\1]]').gsub(
"&rarr;", "→").gsub(/<<(.*?)>>/) { |match|
ch = crossrefs[$1]
h = headrefs[$1]
# p " #{match} -> #{ch}, #{h}"
if ch
# if local do not add the file
if ch==chap
"<<r#{$1}>>"
else
"<<#{ch}#r#{$1}>>"
end
elsif h
if h==chap
"<<#{chap}>>"
else
"<<#{h}##{h}>>"
end
end
}
File.open(filename, "w") {|file| file.puts new_contents }
}
}

chapters.each { | num, title |
if num =~ /[ABC]/
chap = "#{num}-#{title}"
else
chap = "ch#{num}-#{title}"
end
Dir[File.join ["book","#{num}-#{title}" ,"1*.asc"]].map { |filename|
content = File.read (filename)
new_contents = content.gsub(/include::(.*?)asc/) {|match|
"include::book/#{num}-#{title}/#{$1}asc"}
`git rm -f #{filename}`
File.open("#{chap}.asc", "w") {|file|
file.puts "[##{chap}]\n"
file.puts new_contents }
`git add "#{chap}.asc"`
}
}
end
end



task :default => "book:build"

0 comments on commit 63dfdd1

Please sign in to comment.