Sunday, April 8, 2012

Git-Scribe Rebase

‹prev | My Chain | next›

I am sorely tempted to move along with SPDY Book today, but how can I with my fork having so badly diverged from git-scribe? A git-rebase is gonna be painful, but what kind of citizen of the OSS world am I if I do not at least try?

And, indeed, it is painful. I lose count of the number of conflicts along the way, but I eventually reach the last conflict and fix it:
➜  git-scribe(master)  git fetch upstream  
➜  git-scribe(master)  git rebase upstream/master
...
Applying: Re-org XSL cover page "code" in clean code order
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging docbook-xsl/fo.xsl
CONFLICT (content): Merge conflict in docbook-xsl/fo.xsl
Failed to merge in the changes.
Patch failed at 0030 Re-org XSL cover page "code" in clean code order

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

➜  git-scribe  gst
# Not currently on any branch.
# Unmerged paths:
#   (use "git reset HEAD ..." to unstage)
#   (use "git add/rm ..." as appropriate to mark resolution)
#
#       both modified:      docbook-xsl/fo.xsl
#
no changes added to commit (use "git add" and/or "git commit -a")
➜  git-scribe  git add docbook-xsl/fo.xsl
➜  git-scribe  git rebase --continue     
Applying: Re-org XSL cover page "code" in clean code order
Applying: ensure that code blocks don't break over pages, making it way easier to read
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.
Applying: Post commit-hook for mobi processing.
Applying: Remove useless puts
Applying: Remove copy dest to deal with symbolic links
Applying: Admonition icons for PDF and epub.
Applying: Grey background for code samples in epub
Applying: Note on my fork
I keep a reference to my original fork so that I can tell what might have changed after rebasing. My original fork was working pretty well for me and I do not want to suffer for having done the right thing. The reference is at:
➜  git-scribe git:(master) git co -b original-fork b80326e
Switched to a new branch 'original-fork'
Testing the output in a bunch of different devices is a huge, long feedback cycle pain, so first up, I run the test suite:
➜  git-scribe git:(master) rake
Started
...F.F....E.FFF...

1) Failure:
test_scribe_can_generate_a_mobi(scribe_gen_tests)

2) Failure:
test_scribe_can_generate_a_pdf_with_syntax_highlighting(scribe_gen_tests)

3) Error:
test_scribe_can_generate_site_with_syntax_highlighting(scribe_gen_tests):

4) Failure:
test_scribe_generates_a_mobi_with_a_cover_and_TOC(scribe_gen_tests)

5) Failure:
test_scribe_generates_an_epub_with_a_cover(scribe_gen_tests)

6) Failure:
test_will_not_respond_to_non_thing(scribe_gen_tests) [/home/cstrom/repos/git-scribe/test/gen_test.rb:9]:

18 tests, 38 assertions, 5 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
66.6667% passed

0.41 tests/s, 0.86 assertions/s
Ugh. The syntax highlighting errors I expect—that just will not work on Ubuntu since those tests come from upstream, which is pegged to OSX. The cover errors are more worrisome. They turn out to have been introduced by my lovely admonition icons, which I added to my docinfo template (used by the underlying asciidoc tool chain). I added them to the cover media object, which seems to wreak havoc with the actual cover image:
<mediaobject role="cover">
  <imageobject>
    <imagedata fileref="images/icons/note.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="images/icons/caution.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="images/icons/important.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="images/icons/tip.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="images/icons/warning.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="{{cover_image}}" format="JPG"/>
  </imageobject>
  <textobject><phrase>{{title}}</phrase></textobject>
</mediaobject>
Removing those images gets the tests passing, but now I lack for my lovely admonition icons.

I am forced to call it a day here. Hopefully tomorrow I can find another place to include these icons so that nothing breaks.

Update: Figured out a way to do this. I move the admonition icons into a separate mediaobject:
<mediaobject role="cover">
  <imageobject>
    <imagedata fileref="{{cover_image}}" format="JPG"/>
  </imageobject>
  <textobject><phrase>{{title}}</phrase></textobject>
</mediaobject>
<mediaobject role="icons">
  <imageobject>
    <imagedata fileref="images/icons/note.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="images/icons/caution.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="images/icons/important.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="images/icons/tip.png" format="PNG"/>
  </imageobject>
  <imageobject>
    <imagedata fileref="images/icons/warning.png" format="PNG"/>
  </imageobject>
</mediaobject>
That seems to be enough for the underlying asciidoc / a2x toolchain to pick up both the cover image and the admonition icons. Multiple root elements in an XML file like book-docinfo.xml does not seem like a recipe for long term success. But I'll take a short term win. Especially when there are unit tests to catch regressions.


Day #350

No comments:

Post a Comment