Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
language: ruby
sudo: false
git:
depth: false
cache: bundler
before_install:
- bundle install
after_success:
- script/tag_on_master
- wget https://raw.githubusercontent.com/progit/progit2-pub/master/bootstrap.sh
- sh bootstrap.sh
script: bundle exec rake book:build
env:
secure: "O+YCTDgLfCYAJjjOv2sApDRV5NJe6pkhiYIkORFuf2flO8HE72fEtDRpSWh1vulnIH6AjRK2jH7C8qA3MVbUO8D0io+Ha+vnbMXIp1JPCptcJNEkJrW13VTR66SWOzsgLp3mCrIC+YdE2JoYWGcnDsRMQwdnrWnxBzSOd22ZKzU="

before_deploy: bundle install && bundle exec rake book:build
after_success: bundle exec rake book:tag
deploy:
provider: releases
file_glob: true
file:
- progit.epub
- progit.mobi
- progit.pdf
- progit*.epub
- progit*.mobi
- progit*.pdf
skip_cleanup: true
on:
tags: true
api-key:
secure: "l3XdupX6dT48IoTieJXrd7Yx8+KhiR2QYrNrDzT6RKxA7UyXGSP/axsVerg7OjKfIHWZgDJRVzcc2RswE+Xjw9sOY8r2h2q9uCwj8G0EqtFbtgGK0La5LB0euh0tNJN8GLFj1OdSZGY7dWWK88GXeHCua2WSify0V79R4ClIM+s="
api-key: $GITHUB_API_TOKEN
branches:
only:
- master
- /^2\.1(\.\d+)+$/

addons:
apt:
packages:
- epubcheck
notifications:
email:
on_success: never
Expand Down
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ gem 'awesome_print'

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'
gem 'github_changelog_generator', github: 'Furtif/github-changelog-generator'
1 change: 1 addition & 0 deletions README.asc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
image::https://travis-ci.org/progit/progit2-bg.svg?branch=master[]
= Pro Git, Второ издание

Това е второто издание на книгата Pro Git.
Expand Down
235 changes: 226 additions & 9 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,243 @@
# coding: utf-8
require 'octokit'
require 'github_changelog_generator'

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

module GitHubChangelogGenerator

#OPTIONS = %w[ user project token date_format output
# bug_prefix enhancement_prefix issue_prefix
# header merge_prefix issues
# add_issues_wo_labels add_pr_wo_labels
# pulls filter_issues_by_milestone author
# unreleased_only unreleased unreleased_label
# compare_link include_labels exclude_labels
# bug_labels enhancement_labels
# between_tags exclude_tags exclude_tags_regex since_tag max_issues
# github_site github_endpoint simple_list
# future_release release_branch verbose release_url
# base configure_sections add_sections]

def get_log(&task_block)
options = Parser.default_options
yield(options) if task_block

options[:user],options[:project] = ENV['TRAVIS_REPO_SLUG'].split('/')
options[:token] = ENV['GITHUB_API_TOKEN']
options[:unreleased] = false

generator = Generator.new options
generator.compound_changelog
end

module_function :get_log
end

namespace :book do
desc 'build basic book formats'
task :build do

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

# detect if the deployment is using glob
travis = File.read(".travis.yml")
version_string = ENV['TRAVIS_TAG'] || '0'
if travis.match(/file_glob/)
progit_v = "progit_v#{version_string}"
else
progit_v = "progit"
end
text = File.read('progit.asc')
new_contents = text.gsub("$$VERSION$$", version_string).gsub("$$DATE$$", Time.now.strftime("%Y-%m-%d"))
File.open("#{progit_v}.asc", "w") {|file| file.puts new_contents }

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

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

exec_or_raise("epubcheck #{progit_v}.epub")

puts "Converting to Mobi (kf8)..."
`bundle exec asciidoctor-epub3 -a ebook-format=kf8 progit.asc`
puts " -- Mobi output at progit.mobi"
exec_or_raise("bundle exec asciidoctor-epub3 -a ebook-format=kf8 #{progit_v}.asc")
# remove the fake epub that would shadow the really one
exec_or_raise("rm progit*kf8.epub")
puts " -- Mobi output at #{progit_v}.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"
if (repo == "progit/progit2-zh")
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=KaiGenGothicCN #{progit_v}.asc")
elsif (repo == "progit/progit2-ja")
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_v}.asc")
elsif (repo == "progit/progit2-zh-tw")
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=KaiGenGothicTW #{progit_v}.asc")
else
exec_or_raise("bundle exec asciidoctor-pdf #{progit_v}.asc 2>/dev/null")
end
puts " -- PDF output at #{progit_v}.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'))
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}"
if (ENV['TRAVIS_BRANCH']=='master')
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 #{last_version}"
elsif (ENV['TRAVIS_TAG'])
version = ENV['TRAVIS_TAG']
changelog = GitHubChangelogGenerator.get_log do |config|
config[:since_tag] = last_version
end
credit_line = "*This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
changelog.gsub!(credit_line, "")
@octokit.create_release(repo, new_version, {:name => "v#{new_version}", :body => changelog})
p "Created release #{new_version}"
else
p 'This only runs on a commit to master'
end
else
p 'No interaction with GitHub'
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(/\[\[([_a-z0-9]*?)\]\]/)
}.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(/\[\[([_a-z0-9]*?)\]\]/, '[[r\1]]').gsub(
"&rarr;", "→").gsub(/<<([_a-z0-9]*?)>>/) { |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
else
p "could not match xref #{$1}"
"<<#{$1}>>"
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"
1 change: 0 additions & 1 deletion book/01-introduction/sections/basics.asc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ Staging областта представлява файл, който се па
Един типичен Git работен процес изглежда по подобен начин:

1. Вие променяте файлове в работната област.
2. Вие индексирате(stage-вате) файловете, добавяйки snapshot-и от тях към staging областта.
2. Вие селективно индексирате (stage-вате) само промените, които искате да са част от следващия ви къмит.
3. Вие правите къмит, при което файловете се вземат така както изглеждат в staging областта и този snapshot се записва за постоянно във вашата Git директория.

Expand Down
2 changes: 1 addition & 1 deletion book/02-git-basics/sections/undoing.asc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Changes to be committed:
Важно е да се помни, че `git checkout -- <file>` е опасна команда.
Всички промени, които сте правили по този файл ще изчезнат необратимо -- Git просто копира друг файл върху него.
Никога не ползвайте тази команда, освен ако не сте абсолютно сигурни, че не желаете промените във файла.

=====

Ако желаете да запазите промените си по файла, но все още държите да пазите този файл настрани от проекта към дадения момент, има по-добри начини да го направите, ще ги разгледаме в материала за скриване (stashing) и клонове код (branching).<<ch03-git-branching#ch03-git-branching>>

Expand Down
4 changes: 2 additions & 2 deletions book/06-github/sections/2-contributing.asc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[NOTE]
====
В исторически план, понятието ``fork'' се е възприемало и като негативно действие, при което злонамерен потребител взема проект с отворен код и го насочва в друга посока създавайки понякога конкурентен проект и разделяйки участващите в проекта потребители.
В GitHub, ``fork'' е просто същия проект преместен във вашия namespace, който можете да променяте, начин да дадете вашия принос към оригиналния проект в по-достъпен стил.
В GitHub, ``fork'' е просто същия проект преместен във вашия namespace, който можете да променяте, начин да дадете вашия принос към оригиналния проект в по-достъпен стил.
====

По този начин, собствениците на проектите са освободени от грижата да дават права за писане на потребителите-сътрудници.
Expand All @@ -25,7 +25,7 @@ image::images/forkbutton.png[Бутонът ``Fork''.]

След няколко секунди, ще бъдете прехвърлени към новата страница на проекта, където вече ще имате права за писане.


[[_github_flow]]
==== Работния процес в GitHub

(((GitHub, Flow)))
Expand Down
10 changes: 5 additions & 5 deletions book/06-github/sections/3-maintaining.asc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ image::images/newrepoform.png[Формата ``new repository''.]
Засега просто натиснете бутона ``Create Repository'' и вече разполагате с ново хранилище в GitHub, с име `<user>/<project_name>`.

Понеже все още нямате качен никакъв код, GitHub ще ви предложи инструкции как да създадете ново Git хранилище или да се свържете със съществуващ Git проект.
Няма да навлизаме в детайли за това, ако имате нужда от припомняне, погледнете <<_git_basics_chapter#_git_basics_chapter>>.
Няма да навлизаме в детайли за това, ако имате нужда от припомняне, погледнете <<ch02-git-basics-chapter#ch02-git-basics-chapter>>.

Сега проектът ви се хоства в GitHub и можете да изпратите URL-а на всеки, с който желаете да го споделите.
Всеки GitHub проект е достъпен през HTTPS като `https://github.com/<user>/<project_name>`, а също и през SSH като `git@github.com:<user>/<project_name>`.
Expand Down Expand Up @@ -80,7 +80,7 @@ image::images/maint-01-email.png[Email известяване за нов Pull R
Предоставят ви се и няколко URL-а, които можете да ползвате от командния ред.

Ако виждате ред `git pull <url> patch-1`, това е прост начин да слеете отдалечен клон без да трябва да добавяте remote.
Видяхме това в <<_distributed_git#_checking_out_remotes>>.
Видяхме това в <<ch05-distributed-git#_checking_out_remotes>>.
Ако искате, можете да създадете и да превключите в topic клон и след това да изпълните тази команда за да слеете Pull Request-а.

Другите интересни URL-и са `.diff` и `.patch` URL-ите, които както можете да предположите, осигуряват unified diff и patch версии на Pull Request-а.
Expand All @@ -93,7 +93,7 @@ $ curl http://github.com/tonychacon/fade/pull/1.patch | git am

===== Съвместна работа по Pull Request

Както видяхме в <<_github#_github_flow>>, сега можете да проведете дискусия с човека, който е пуснал Pull Request-а.
Както видяхме в <<ch06-github#_github_flow>>, сега можете да проведете дискусия с човека, който е пуснал Pull Request-а.
Можете да коментирате специфични редове код, да коментирате цели къмити или целия Pull Request, използвайки GitHub Flavored Markdown където искате.

Всеки път, когато някой друг коментира Pull Request-а, ще продължавате да получавате имейл нотификации, така че да сте наясно какво се случва.
Expand All @@ -120,12 +120,12 @@ image::images/maint-02-merge.png[Merge бутон]
===== Pull Request референции

Ако си имате работа с *много* Pull Request-и и не искате да добавяте цял куп remotes или да правите еднократни изтегляния всеки път, GitHub ви предоставя един хитър трик за улеснение в работата.
Това е материал за напреднали и ще видим детайлите за него в <<_git_internals#_refspec>>, но може да е много полезен.
Това е материал за напреднали и ще видим детайлите за него в <<ch10-git-internals#_refspec>>, но може да е много полезен.

GitHub в действителност представя Pull Request клоновете за дадено хранилище като вид псевдо-клонове на сървъра.
По подразбиране, вие не ги получавате при клониране, но те са там по един маскиран начин и можете да получите достъп до тях лесно.

За да демонстрираме това, ще използваме low-level команда (често наричана ``plumbing'' команда, за която ще научим повече в <<_git_internals#_plumbing_porcelain>>) наречена `ls-remote`.
За да демонстрираме това, ще използваме low-level команда (често наричана ``plumbing'' команда, за която ще научим повече в <<ch10-git-internals#_plumbing_porcelain>>) наречена `ls-remote`.
Обикновено тази команда не се използва ежедневно в Git операциите, но е полезна защото ни показва какви референции съществуват на сървъра.

Ако стартираме тази команда за ``blink'' хранилището, което ползвахме по-рано, ще видим списък от всички клонове, тагове и други референции в него.
Expand Down
Loading