From 8eb8efd5ff120384daf0645d6125bf51a595410f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= Date: Sat, 31 Oct 2020 18:31:42 +0100 Subject: [PATCH 1/2] fix mistakes in the book that prevent compilation --- LICENSE.asc | 5 +---- book/01-introduction/sections/installing.asc | 2 +- book/05-distributed-git/sections/maintaining.asc | 2 +- book/08-customizing-git/sections/attributes.asc | 2 +- book/09-git-and-other-scms/sections/import-p4.asc | 2 +- book/10-git-internals/sections/objects.asc | 2 +- book/10-git-internals/sections/transfer-protocols.asc | 2 +- book/A-git-in-other-environments/sections/visualstudio.asc | 2 +- 8 files changed, 8 insertions(+), 11 deletions(-) diff --git a/LICENSE.asc b/LICENSE.asc index 490603e1..81f2824e 100644 --- a/LICENSE.asc +++ b/LICENSE.asc @@ -1,4 +1 @@ -[preface] -== Licence - -include::../LICENSE.asc[] +This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. diff --git a/book/01-introduction/sections/installing.asc b/book/01-introduction/sections/installing.asc index 33ba9e8f..0b844522 100644 --- a/book/01-introduction/sections/installing.asc +++ b/book/01-introduction/sections/installing.asc @@ -4,7 +4,7 @@ Git'i istifadə etməyə başlamazdan qabaq öz komputerinizdə onu hazır etmə Əgər artıq yüklənmiş olsanız belə, sonuncu versiyaya yeniləmək daha yaxşı idea olacaqdır. Onu başqa quraşdırıcı vasitəsi ilə paket formasında ya da qaynaq kodlarını yükləyib özünüz kompayl edə bilərsiniz. -[QEYD] +[NOTE] ==== Bu kitab *2.8.0* versiyalı Git'dən istifadə edilərək yazılıb. Bizim istifadə etdiyimiz əmrlərin bir çoxu Git'in bir çox köhnə versiyalarında işləməlidir, köhnə versiyanı istifadə edirsinizsə, əmrlərin bəziləri işləməyə və ya fərqlilik göstərə bilər. diff --git a/book/05-distributed-git/sections/maintaining.asc b/book/05-distributed-git/sections/maintaining.asc index 0715e16a..62c5af7e 100644 --- a/book/05-distributed-git/sections/maintaining.asc +++ b/book/05-distributed-git/sections/maintaining.asc @@ -297,7 +297,7 @@ Daha vacib bir layihəniz varsa, iki fazalı birləşmə dövründən istifadə Bu ssenaridə `master` and `develop` olan iki uzun filial var, `master` yalnız çox sabit bir buraxılma kəsildikdə və bütün yeni kod `develop` branch-na inteqrasiya edildikdə yeniləndiyini müəyyənləşdirirsiniz. Mütəmadi olaraq bu branch-ların hər ikisini public depolarına aparırsınız. -Hər dəfə (<>) birləşmək üçün yeni bir mövzu branch-ı varsa, onu `develop`-a (<>) birləşdirirsiniz; sonra bir etiketi etiketlədikdə, stabil `develop` branch-ın olduğu yerə `master` sürətlə irəliləyir (<>). +Hər dəfə (<>) birləşmək üçün yeni bir mövzu branch-ı varsa, onu `develop`-a (<>) birləşdirirsiniz; sonra bir etiketi etiketlədikdə, stabil `develop` branch-ın olduğu yerə `master` sürətlə irəliləyir (<>). [[merwf_c]] .Mövzu branch-ı birləşmədən əvvəl diff --git a/book/08-customizing-git/sections/attributes.asc b/book/08-customizing-git/sections/attributes.asc index 0f219d9e..4fbd80fe 100644 --- a/book/08-customizing-git/sections/attributes.asc +++ b/book/08-customizing-git/sections/attributes.asc @@ -194,7 +194,7 @@ CVS-də və ya Subversion-da keyword əvəzetməsindən istifadə etmisinizsə, commit/checkout fayllarında dəyişiklik etmək üçün öz filtrlərinizi yaza biləcəyiniz ortaya çıxdı. Bunlara ``clean'' və ``smudge'' filtrləri deyilir. -`.gitattributes` faylında, müəyyən yollar üçün bir filtr qura və sonra sənədləri yoxlanılmadan dərhal əvvəl işləyəcək skriptlər qura bilərsiniz (``smudge'', bax <>) və bunlardan bir az əvvəl. səhnələşdirilmişdir (``clean'', bax <>). +`.gitattributes` faylında, müəyyən yollar üçün bir filtr qura və sonra sənədləri yoxlanılmadan dərhal əvvəl işləyəcək skriptlər qura bilərsiniz (``smudge'', bax <>) və bunlardan bir az əvvəl. səhnələşdirilmişdir (``clean'', bax <>). Bu filtrlər hər cür əyləncəli şeylər etmək üçün qurula bilər. [[filters_a]] diff --git a/book/09-git-and-other-scms/sections/import-p4.asc b/book/09-git-and-other-scms/sections/import-p4.asc index 664701d0..771d4874 100644 --- a/book/09-git-and-other-scms/sections/import-p4.asc +++ b/book/09-git-and-other-scms/sections/import-p4.asc @@ -8,7 +8,7 @@ Yuxarıda müzakirə etdiyimiz kimi, Git və Perforce-un bir-birlərinə danış ===== Perforce Git Fusion Git Fusion bu prosesi kifayət qədər ağrısız edir. -Bir konfiqurasiya sənədindən istifadə edərək layihə parametrlərinizi, istifadəçi xəritələrinizi və branch-larınızı konfiqurasiya etməyiniz kifayətdir (<>-da müzakirə olunduğu kimi) və deponu klonlayın. +Bir konfiqurasiya sənədindən istifadə edərək layihə parametrlərinizi, istifadəçi xəritələrinizi və branch-larınızı konfiqurasiya etməyiniz kifayətdir (<<_p4_git_fusion>>-da müzakirə olunduğu kimi) və deponu klonlayın. Git Fusion, yerli bir Git deposuna bənzər bir şey buraxır, daha sonra istəsəniz local bir Git hostuna push etməyə hazırdır. İstəsəniz, Perforce'ı Git ev sahibi kimi istifadə edə bilərsiniz. diff --git a/book/10-git-internals/sections/objects.asc b/book/10-git-internals/sections/objects.asc index 3b5c51a4..fdf08232 100644 --- a/book/10-git-internals/sections/objects.asc +++ b/book/10-git-internals/sections/objects.asc @@ -259,7 +259,7 @@ $ echo 'First commit' | git commit-tree d8329f fdf4fc3344e67ab068f836878b6c4951e3b15f3d ---- -[QEYD] +[NOTE] ==== Fərqli yaradılış müddəti və müəllif məlumatları səbəbindən fərqli bir hash dəyəri əldə edəcəksiniz. Üstəlik, prinsip etibarilə hər hansı bir commit obyekti məlumatların verildiyi dəqiq şəkildə çoxaldıla bilsə də, bu kitabın inşaatının tarixi təfərrüatları, çap edilən commit-lərin verilmiş commit-lərə uyğun olmaya biləcəyini göstərir. diff --git a/book/10-git-internals/sections/transfer-protocols.asc b/book/10-git-internals/sections/transfer-protocols.asc index 81ca92b4..f16c4c75 100644 --- a/book/10-git-internals/sections/transfer-protocols.asc +++ b/book/10-git-internals/sections/transfer-protocols.asc @@ -8,7 +8,7 @@ Bu bölmə bu iki əsas protokolun necə işlədiyini tez bir zamanda əhatə ed Yalnız bir oxunuşda HTTP üzərindən təqdim ediləcək bir depo qurursanız, dumb protokolundan istifadə edilməsi ehtimalı böyükdür. Bu protokol ``dumb'' adlanır, çünki nəqliyyat prosesi zamanı server tərəfində Git-ə məxsus bir kod tələb olunmur; gətirmə prosesi, müştərinin serverdəki Git deposunun tərtibatını qəbul edə biləcəyi bir sıra HTTP `GET` istəkləridir. -[QEYD] +[NOTE] ==== Bu günlərdə dumb protokolu kifayət qədər nadir hallarda istifadə olunur. diff --git a/book/A-git-in-other-environments/sections/visualstudio.asc b/book/A-git-in-other-environments/sections/visualstudio.asc index 6f57491b..12541b31 100644 --- a/book/A-git-in-other-environments/sections/visualstudio.asc +++ b/book/A-git-in-other-environments/sections/visualstudio.asc @@ -19,7 +19,7 @@ Bu, Git action-ları həyata keçirmək üçün bir mərkəzdir; kod yazarkən, [[vs_home]] .Visual Studio'da bir Git deposu üçün "Ev" görünüşü -image::images/vs-2.png[Visual Studio'da bir Git deposu üçün "Ev" görünüşü] +image::images/vs-2.png[Visual Studio'da bir Git deposu üçün “Ev” görünüşü] Visual Studio artıq Git üçün güclü bir iş odaklı bir interfeysə sahibdir. Xətti tarix görünüşü, diff görüntüləyici, uzaqdan əmrlər və bir çox digər imkanlar daxildir. From f5dafcc48875df5e860671ca89d4cbe3bc90001e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-No=C3=ABl=20Avila?= Date: Sat, 31 Oct 2020 18:32:14 +0100 Subject: [PATCH 2/2] update compilation recipes --- Gemfile | 13 ++- Rakefile | 251 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 239 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index 4ecffb4f..a3697ffc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,16 +1,21 @@ source 'https://rubygems.org' gem 'rake' -gem 'asciidoctor', '1.5.6.1' +gem 'asciidoctor', '1.5.6.2' gem 'json' gem 'awesome_print' -gem 'asciidoctor-epub3', :git => 'https://github.com/asciidoctor/asciidoctor-epub3' +gem 'ttfunk', '1.5.1' +gem 'asciidoctor-epub3', '1.5.0.alpha.9' 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 'epubcheck-ruby' + +gem 'octokit' +gem 'github_changelog_generator', github: 'Furtif/github-changelog-generator' diff --git a/Rakefile b/Rakefile index 5b5702aa..4ba55c80 100644 --- a/Rakefile +++ b/Rakefile @@ -1,35 +1,244 @@ +# 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 - begin - version_string = ENV['TRAVIS_TAG'] || `git describe --tags`.chomp - if version_string.empty? - version_string = '0' - end - date_string = Time.now.strftime("%Y-%m-%d") - params = "--attribute revnumber='#{version_string}' --attribute revdate='#{date_string}'" - puts "Generating contributors list" - `git shortlog -s | grep -v -E "(Straub|Chacon)" | cut -f 2- | column -c 120 > book/contributors.txt` + puts "Generating contributors list" + exec_or_raise("git shortlog -s --all $translation_origin | grep -v -E '(Straub|Chacon)' | cut -f 2- | sort | column -c 110 > 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 #{params} progit.asc` - puts " -- HTML output at progit.html" + puts "Converting to HTML..." + exec_or_raise("bundle exec asciidoctor -a data-uri #{progit_v}.asc") + puts " -- HTML output at #{progit_v}.html" - puts "Converting to EPub..." - `bundle exec asciidoctor-epub3 #{params} progit.asc` - puts " -- Epub output at progit.epub" + puts "Converting to EPub..." + exec_or_raise("bundle exec asciidoctor-epub3 #{progit_v}.asc") + puts " -- Epub output at #{progit_v}.epub" - puts "Converting to Mobi (kf8)..." - `bundle exec asciidoctor-epub3 #{params} -a ebook-format=kf8 progit.asc` - puts " -- Mobi output at progit.mobi" + exec_or_raise("epubcheck #{progit_v}.epub") - puts "Converting to PDF... (this one takes a while)" - `bundle exec asciidoctor-pdf #{params} progit.asc 2>/dev/null` - puts " -- PDF output at progit.pdf" + repo = ENV['TRAVIS_REPO_SLUG'] + puts "Converting to PDF... (this one takes a while)" + 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") + elsif (repo == "progit/progit2-ko") + 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=KaiGenGothicKR #{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) + begin + @octokit.create_ref(repo, "tags/#{new_version}", obj.sha) + rescue + p "the ref already exists ???" + end + 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( + "→", "→").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 + "<>" + 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"