Kevin Deldycke - l10nhttps://kevin.deldycke.com/2015-09-28T21:19:53+02:00How-To Reconcile Metadata Differences of a Messed Up Pull-Request2015-09-28T21:19:53+02:002015-09-28T21:19:53+02:00Kevin Deldycketag:kevin.deldycke.com,2015-09-28:/2015/09/fixing-pull-request-over-diff/<p>I was browsing upcoming changes in <a href="https://github.com/python-babel/babel">Babel </a> today when I spotted a typo. For these kind of tiny fixes I don&rsquo;t bother: I simply edit the file through GitHub <span class="caps">UI</span> and let it forked the repository, name the branch and propose a <a href="https://github.com/python-babel/babel/pull/264">pull request </a> for&nbsp;me.</p> <p>But now the …</p><p>I was browsing upcoming changes in <a href="https://github.com/python-babel/babel">Babel </a> today when I spotted a typo. For these kind of tiny fixes I don&rsquo;t bother: I simply edit the file through GitHub <span class="caps">UI</span> and let it forked the repository, name the branch and propose a <a href="https://github.com/python-babel/babel/pull/264">pull request </a> for&nbsp;me.</p> <p>But now the <a href="https://github.com/python-babel/babel/pull/264#issuecomment-143711250">maintainer asked me </a> to make my commit message more informative. Fair enough. This shouldn&rsquo;t take&nbsp;long.</p> <p>So I fetched a local copy of my fork, made the edit and pushed it&nbsp;back:</p> <div class="highlight"><pre><span></span>$ git clone https://github.com/kdeldycke/babel.git $ <span class="nb">cd</span> ./babel $ git checkout patch-1 $ git rebase -i HEAD~10 $ git push --force </pre></div> <p>It&rsquo;s only after looking at the pull request in GitHub that I realized the last ten commits were marked as new and different, while I expected only last one to be featured as a change against <code>master</code>. In a word, I&nbsp;messed-up.</p> <p>A closer inspection revealed that <code>rebase</code> seems to have introduced extra <code>Committer</code> metadata. And my confidence that it would not made me force the subsequent <code>push</code>.</p> <p>It&rsquo;s now time to untangle this mess. I first tried to realign authorship metadata on the last 10 commits (<a href="https://github.com/python-babel/babel/commit/665212">665212 </a> being my <span class="caps">PR</span>&rsquo;s root, i.e. the last untouched&nbsp;commit):</p> <div class="highlight"><pre><span></span>$ git filter-branch --force --env-filter <span class="s1">&#39;</span> <span class="s1"> export GIT_COMMITTER_NAME=&quot;$GIT_AUTHOR_NAME&quot;</span> <span class="s1"> export GIT_COMMITTER_EMAIL=&quot;$GIT_AUTHOR_EMAIL&quot;</span> <span class="s1">&#39;</span> -- <span class="m">665212</span>..patch-1 </pre></div> <p>Still, commit checksums did not returned to their original value. There must be other metadata&nbsp;involved.</p> <p>As I wasn&rsquo;t ready to waste time on doctoring each commit to find the underlaying differences, I simply rebased everything to&nbsp;master:</p> <div class="highlight"><pre><span></span>$ git rebase master $ git pull $ git rebase origin/master $ git push --force </pre></div> <p>It did work and my <span class="caps">PR</span> was now clean and&nbsp;tidy.</p>I18n / L10n Commands2006-11-22T01:09:21+01:002006-11-22T01:09:21+01:00Kevin Deldycketag:kevin.deldycke.com,2006-11-22:/2006/11/i18n-l10n-commands/<ul> <li> <p>Check a <code>.po</code> file:</p> <div class="highlight"><pre><span></span>$ msgfmt -c -v -o /dev/null file.po </pre></div> </li> <li> <p>Wipe out a <code>.po</code> file and keep only translated&nbsp;messages:</p> <div class="highlight"><pre><span></span>$ msgattrib --translated -o cleaned.po messy.po </pre></div> </li> <li> <p>Delete duplicate messages in a <code>.po</code> file:</p> <div class="highlight"><pre><span></span>$ msguniq -o no_duplicate.po duplicate_content.po </pre></div> </li> <li> <p>Show differences between two <code>.po</code> files (thanks to …</p></li></ul><ul> <li> <p>Check a <code>.po</code> file:</p> <div class="highlight"><pre><span></span>$ msgfmt -c -v -o /dev/null file.po </pre></div> </li> <li> <p>Wipe out a <code>.po</code> file and keep only translated&nbsp;messages:</p> <div class="highlight"><pre><span></span>$ msgattrib --translated -o cleaned.po messy.po </pre></div> </li> <li> <p>Delete duplicate messages in a <code>.po</code> file:</p> <div class="highlight"><pre><span></span>$ msguniq -o no_duplicate.po duplicate_content.po </pre></div> </li> <li> <p>Show differences between two <code>.po</code> files (thanks to&nbsp;Jérome!):</p> <div class="highlight"><pre><span></span>$ msgcat -u file1.po file2.po &gt; diff.po </pre></div> </li> <li> <p>Generate a <code>.mo</code> file from a <code>.po</code> file:</p> <div class="highlight"><pre><span></span>$ msgfmt -o target.mo source.po </pre></div> </li> <li> <p>If you want to have command-line tools use raw string instead of localized ones, add the following directives to your <code>~/.bash_profile</code>:</p> <div class="highlight"><pre><span></span>$ <span class="nb">export</span> <span class="nv">LANGUAGE</span><span class="o">=</span>C $ <span class="nb">export</span> <span class="nv">LANG</span><span class="o">=</span>C $ <span class="nb">export</span> <span class="nv">LC_MESSAGES</span><span class="o">=</span>C </pre></div> </li> </ul>