<commit_before>{% extends 'missions/diffpatch/base.html' %}
{% comment %}
# This file is part of OpenHatch.
# Copyright (C) 2010 <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}


{% block mission_main %}
<div class='submodule fat'>
  <div class='head'>
    <h3>Diffing entire directories</h3>
  </div>
  <div class="body">
    <h2>Diffing entire directories</h2>
    <p>With pancake success under your belt, your publisher invited you to write a new book: <cite>Things to eat with oven pancakes</cite>.</p>

    <p>
      This second book was a smash-hit in England! Your publisher has asked you to prepare an edition for the United States of America.
    </p>

    <p>Wise yet shrewd, you realize that the only change you'd need to make to your cookbook would be to
      replace every occurrence of the word "aubergine" with "eggplant". To make life easy for your
      publisher, you decide to submit a <em>recursive diff</em> that contains just this change,
      applied to all the files in your cookbook.
    </p>

    <p>Here is your mission:</p>
    <ul class="raquo_bullets">
      <li><a href="{% url mysite.missions.diffpatch.views.diffrecursive_get_original_tarball %}">Download this tarball</a> containing your work targeted at the UK.</li>
      <li>Unpack the tarball, and make a second copy.</li>
      <li>In that second copy, find all places where "aubergine" is mentioned and replace them with the synonym, "eggplant". (If you see "Aubergine" with a capital "A", replace that with a similarly-capitalized word!)</li>
      <li>Make a unified diff of your changes.  It should be possible to apply it with "patch -p1" from the "recipes" directory.  (One way to do this is <code>diff -ur recipes recipes-us</code>, where <code>recipes</code> is an unmodified copy of the <code>recipes</code> directory.)</li>
    </ul>

    <p>Since this is a larger patch, you will be uploading it as a file rather than just pasting it in.  (Also, if you're in the mood for some cooking after you complete the mission, we'd love to know how one of those recipes turns out.  But that's not part of the mission.)</p>

    <h2>Context in open source</h2>
    <p>When contributing changes to a project, often your changes
      will involve more than one file, so it makes sense to submit
      all of those changes in one shot, especially if the changes
      depend on one another or it is the same adjustment to a
      number of files.</p>

    <form method="post" enctype="multipart/form-data" action="{% url mysite.missions.diffpatch.views.diffrecursive_submit %}#diffrecursive-form">{% csrf_token %}
      <div class="form-row file-upload-row">
        <a name="diffrecursive-form"></a>
        Upload the unified diff here:
	{% if diffrecursive_success %}
	<div class="successmsg">
	  <p><strong>You have successfully completed this part of the mission.</strong></p>
	  <p>The patch applies correctly and makes all of the requested changes.</p>
	</div>
	{% endif %}
        {% if diffrecursive_error_message %}
        <ul class="errorlist"><li>{{ diffrecursive_error_message }}</li></ul>
        {% endif %}
        {{ diffrecursive_form.diff.errors }}
        <div class="file-upload">
          {{ diffrecursive_form.diff }}
          <input type="submit" value="Submit" style="float: none;" />
          {% if diffrecursive_done %}
          <br style="clear: left;" />
          <em>You have already completed this part of the mission.</em>
          {% endif %}
	</div>
      </div>
    </form>
    {% if diffrecursive_done %}
    <p class="next_mission_link">
      <a href="{% url mysite.missions.diffpatch.views.recursive_patch %}">
	Try the final step, patching entire directories &raquo;
    </a></p>
    {% endif %}
  </div>
</div>
{% endblock mission_main %}<commit_msg>recursive diff mission: Provide detailed hints<commit_after>{% extends 'missions/diffpatch/base.html' %}
{% comment %}
# This file is part of OpenHatch.
# Copyright (C) 2010 <NAME>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}


{% block mission_main %}
<div class='submodule fat'>
  <div class='head'>
    <h3>Diffing entire directories</h3>
  </div>
  <div class="body">
    <h2>Diffing entire directories</h2>
    <p>With pancake success under your belt, your publisher invited you to write a new book: <cite>Things to eat with oven pancakes</cite>.</p>

    <p>
      This second book was a smash-hit in England! Your publisher has asked you to prepare an edition for the United States of America.
    </p>

    <p>Wise yet shrewd, you realize that the only change you'd need to make to your cookbook would be to
      replace every occurrence of the word "aubergine" with "eggplant". To make life easy for your
      publisher, you decide to submit a <em>recursive diff</em> that contains just this change,
      applied to all the files in your cookbook.
    </p>

    <p>Here is your mission:</p>
    <ul class="raquo_bullets">
      <li><a href="{% url mysite.missions.diffpatch.views.diffrecursive_get_original_tarball %}">Download this tarball</a> containing your work targeted at the UK.</li>
      <li>Unpack the tarball, and make a second copy.</li>
      <li>In that second copy, find all places where "aubergine" is mentioned and replace them with the synonym, "eggplant". (If you see "Aubergine" with a capital "A", replace that with a similarly-capitalized word!)</li>
      <li>Make a unified diff of your changes.  It should be possible to apply it with "patch -p1" from the "recipes" directory.  (One way to do this is <code>diff -ur recipes recipes-us</code>, where <code>recipes</code> is an unmodified copy of the <code>recipes</code> directory.)</li>
    </ul>

    <p>Since this is a larger patch, you will be uploading it as a file rather than just pasting it in.  (Also, if you're in the mood for some cooking after you complete the mission, we'd love to know how one of those recipes turns out.  But that's not part of the mission.)</p>

    <h2>Context in open source</h2>
    <p>When contributing changes to a project, often your changes
      will involve more than one file, so it makes sense to submit
      all of those changes in one shot, especially if the changes
      depend on one another or it is the same adjustment to a
      number of files.</p>

    <form method="post" enctype="multipart/form-data" action="{% url mysite.missions.diffpatch.views.diffrecursive_submit %}#diffrecursive-form">{% csrf_token %}
      <div class="form-row file-upload-row">
        <a name="diffrecursive-form"></a>
        Upload the unified diff here:
	{% if diffrecursive_success %}
	<div class="successmsg">
	  <p><strong>You have successfully completed this part of the mission.</strong></p>
	  <p>The patch applies correctly and makes all of the requested changes.</p>
	</div>
	{% endif %}
        {% if diffrecursive_error_message %}
        <ul class="errorlist"><li>{{ diffrecursive_error_message }}</li></ul>
        {% endif %}
        {{ diffrecursive_form.diff.errors }}
        <div class="file-upload">
          {{ diffrecursive_form.diff }}
          <input type="submit" value="Submit" style="float: none;" />
          {% if diffrecursive_done %}
          <br style="clear: left;" />
          <em>You have already completed this part of the mission.</em>
          {% endif %}
	</div>
      </div>
    </form>
    {% if diffrecursive_done %}
    <p class="next_mission_link">
      <a href="{% url mysite.missions.diffpatch.views.recursive_patch %}">
	Try the final step, patching entire directories &raquo;
    </a></p>
    {% endif %}
    <div id="hint_tabs">
      <ul>
        <li><a href="#hints">Hints</a></li>
        <li><a href="#low">Low</a></li>
        <li><a href="#medium">Medium</a></li>
        <li><a href="#high">High</a></li>
    </ul>
    <div id="hints">
        <p>If you need help with this step, try clicking through these hints.</p>
	<p>The "low" hint level is perfect if you're just confused as to what to do.</p>
	<p>The "high" level is great if you are unfamiliar with the commands and tools you'd use.</p>
    </div>
    <div id="low">
      <pre>man patch</pre>
      <p>or
	<a href="http://linux.die.net/man/1/patch">read the patch page online</a>.</p>
    </div>
    <div id="medium">
      <p>In this mission, you have to do a few things. Tips:</p>
      <ul class="raquo_bullets">
	<li>Make sure to keep a copy of the original around while modifying a copy!</li>
	<li>Use <tt>diff -ur</tt> to create the diff. You need <tt>-u</tt> for a "unified" diff, and <tt>-r</tt> to "recursively" generate a diff across a whole directory of files. (You can combine these parameters into just <tt>-ur</tt>.)</li>
      </ul>
    </div>
    <div id="high">
<p>Open a command propmt, and type these commands in, one at a time. You need to copy them exactly. Make sure to press enter between each one.</p>
      <p>First, create a directory you'll work in and change into it.</p>
      <pre>
	mkdir recursivediff
	cd recursivediff
      </pre>
      <p>Then, download the original collection of recipes.</p>
      <pre>
	wget {{ url_prefix }}{% url mysite.missions.diffpatch.views.diffrecursive_get_original_tarball %}
      </pre>
      <p>Unpack it a once, and rename that to recipes-us indicating that this is the version you'll adjust for American tastes. (This is the copy we'll edit.)</p>
      <pre>
	tar zxvf recipes.tar.gz
	mv recipes recipes-us
      </pre>
      <p>Unpack it again, keeping this one with the original name. (We'll need this original so that <tt>diff</tt> can detect the differences.)</p>
      <pre>
	tar zxvf recipes.tar.gz
      </pre>
<p>Look for the new <tt>recipes-us</tt> directory on your computer, and open up each of the files inside ending in <tt>.txt</tt>. Change "aubergine" to "eggplant", and change "Aubergine" to "Eggplant" (capitalization matters!).</p>
      <p>Go back to the terminal and run this command.</p>
      <pre>
	diff -ur recipes recipes-us > adjust-for-americans.patch
      </pre>
      <p>In the form above, upload the new <tt>adjust-for-americans.patch</tt> file. Then, submit!</p>
    </div>
  </div>
</div>
{% endblock mission_main %}
{'fraction_non_alphanumeric': 0.11525988254886493, 'fraction_numerical': 0.002191252519940398, 'mean_word_length': 3.3089123867069485, 'pattern_counts': {'":': 0, '<': 244, '<?xml version=': 0, '>': 245, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2891838', 'n_tokens_mistral': 3543, 'n_tokens_neox': 3332, 'n_words': 1399}