diff options
-rw-r--r-- | docs/git.rst | 32 | ||||
-rw-r--r-- | docs/mediagoblin.rst | 4 | ||||
-rw-r--r-- | mediagoblin/db/migrations.py | 3 | ||||
-rw-r--r-- | mediagoblin/tests/__init__.py | 15 | ||||
-rw-r--r-- | mediagoblin/tests/tools.py | 23 | ||||
-rw-r--r-- | mediagoblin/util.py | 9 |
6 files changed, 63 insertions, 23 deletions
diff --git a/docs/git.rst b/docs/git.rst index 2836ecd8..ea367846 100644 --- a/docs/git.rst +++ b/docs/git.rst @@ -82,8 +82,8 @@ How to send us your changes There are three ways to let us know how to get it: -1. (preferred) **push changes to publicly available git clone and let - us know where to find it** +1. *(preferred)* **push changes to publicly available git clone and + let us know where to find it** Push your feature/bugfix/issue branch to your publicly available git clone and add a comment to the issue with the url for your @@ -93,14 +93,22 @@ There are three ways to let us know how to get it: Run:: - git format-patch -o patches <remote>/master + git format-patch --stdout <remote>/master > issue_<number>.patch - Then tar up the newly created ``patches`` directory and attach the - directory to the issue. + ``format-patch`` creates a patch of all the commits that are in + your branch that aren't in ``<remote>/master``. The ``--stdout`` + flag causes all this output to go to stdout where it's redirected + to a file named ``issue_<number>.patch``. That file should be + based on the issue you're working with. For example, + ``issue_42.patch`` is a good filename and ``issue_42_rev2.patch`` + is good if you did a revision of it. + + Having said all that, the filename isn't wildly important. Example workflow ================ + Here's an example workflow. @@ -124,20 +132,30 @@ Slartibartfast does the following: git fetch --all -p + This tells ``git fetch`` to fetch all the recent data from all of + the remotes (``--all``) and prune any branches that have been + deleted in the remotes (``-p``). + 2. Creates a branch from the tip of the MediaGoblin repository (the remote is named ``gmg``) master branch called ``bug42_meaning_of_life``:: git checkout -b bug42_meaning_of_life gmg/master + This creates a new branch (``-b``) named ``bug42_meaning_of_life`` based + on the tip of the ``master`` branch of the remote named ``gmg`` and checks + it out. + 3. Slartibartfast works hard on his changes in the ``bug42_meaning_of_life`` branch. When done, he wants to notify us that he has made changes he wants us to see. -4. Slartibartfast pushes his changes to his clone (the remote is named - ``origin``):: +4. Slartibartfast pushes his changes to his clone:: git push origin bug42_meaning_of_life --set-upstream + This pushes the changes in the ``bug42_meaning_of_life`` branch to the + remote named ``origin``. + 5. Slartibartfast adds a comment to issue 42 with the url for his repository and the name of the branch he put the code in. He also explains what he did and why it addresses the issue. diff --git a/docs/mediagoblin.rst b/docs/mediagoblin.rst index ea9c83a7..c437ecc3 100644 --- a/docs/mediagoblin.rst +++ b/docs/mediagoblin.rst @@ -2,6 +2,10 @@ GNU MediaGoblin ================= +.. contents:: Sections + :local: + + What is GNU MediaGoblin ======================= diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index 29bc112f..712f8ab4 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -40,7 +40,8 @@ class MediaEntryMigration(DocumentMigration): Now that we can have rich descriptions via Markdown, we should update all existing entries to record the rich description versions. """ - self.target = {'description_html': {'$exists': False}} + self.target = {'description_html': {'$exists': False}, + 'description': {'$exists': True}} if not self.status: for doc in self.collection.find(self.target): diff --git a/mediagoblin/tests/__init__.py b/mediagoblin/tests/__init__.py index 1f1e23e9..adb6a1b3 100644 --- a/mediagoblin/tests/__init__.py +++ b/mediagoblin/tests/__init__.py @@ -16,12 +16,17 @@ from mediagoblin import mg_globals +from mediagoblin.tests.tools import ( + MEDIAGOBLIN_TEST_DB_NAME, suicide_if_bad_celery_environ) + def setup_package(): - pass + suicide_if_bad_celery_environ() + def teardown_package(): - if mg_globals.db_connection: - print "Killing db ..." - mg_globals.db_connection.drop_database(mg_globals.database.name) - print "... done" + if ((mg_globals.db_connection + and mg_globals.database.name == MEDIAGOBLIN_TEST_DB_NAME)): + print "Killing db ..." + mg_globals.db_connection.drop_database(MEDIAGOBLIN_TEST_DB_NAME) + print "... done" diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index 9e36fc5c..ebb5f1b5 100644 --- a/mediagoblin/tests/tools.py +++ b/mediagoblin/tests/tools.py @@ -28,7 +28,7 @@ from mediagoblin.decorators import _make_safe from mediagoblin.db.open import setup_connection_and_db_from_config -MEDIAGOBLIN_TEST_DB_NAME = '__mediagoblinunittests__' +MEDIAGOBLIN_TEST_DB_NAME = u'__mediagoblin_tests__' TEST_SERVER_CONFIG = pkg_resources.resource_filename( 'mediagoblin.tests', 'test_paste.ini') TEST_APP_CONFIG = pkg_resources.resource_filename( @@ -42,17 +42,23 @@ USER_DEV_DIRECTORIES_TO_SETUP = [ 'media/public', 'media/queue', 'beaker/sessions/data', 'beaker/sessions/lock'] +BAD_CELERY_MESSAGE = """\ +Sorry, you *absolutely* must run nosetests with the +mediagoblin.celery_setup.from_tests module. Like so: +$ CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_tests ./bin/nosetests""" + class BadCeleryEnviron(Exception): pass -def get_test_app(dump_old_app=True): +def suicide_if_bad_celery_environ(): if not os.environ.get('CELERY_CONFIG_MODULE') == \ 'mediagoblin.celery_setup.from_tests': - raise BadCeleryEnviron( - u"Sorry, you *absolutely* must run nosetests with the\n" - u"mediagoblin.celery_setup.from_tests module. Like so:\n" - u"$ CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_tests ./bin/nosetests") + raise BadCeleryEnviron(BAD_CELERY_MESSAGE) + + +def get_test_app(dump_old_app=True): + suicide_if_bad_celery_environ() global MGOBLIN_APP global CELERY_SETUP @@ -78,6 +84,7 @@ def get_test_app(dump_old_app=True): # @@: For now we're dropping collections, but we could also just # collection.remove() ? connection, db = setup_connection_and_db_from_config(app_config) + assert db.name == MEDIAGOBLIN_TEST_DB_NAME collections_to_wipe = [ collection @@ -87,10 +94,6 @@ def get_test_app(dump_old_app=True): for collection in collections_to_wipe: db.drop_collection(collection) - # Don't need these anymore... - del(connection) - del(db) - # TODO: Drop and recreate indexes # setup app and return diff --git a/mediagoblin/util.py b/mediagoblin/util.py index 0e43a1f5..91fbee0a 100644 --- a/mediagoblin/util.py +++ b/mediagoblin/util.py @@ -373,6 +373,10 @@ HTML_CLEANER = Cleaner( def clean_html(html): + # clean_html barfs on an empty string + if not html: + return u'' + return HTML_CLEANER.clean_html(html) @@ -383,6 +387,11 @@ def cleaned_markdown_conversion(text): """ Take a block of text, run it through MarkDown, and clean its HTML. """ + # Markdown will do nothing with and clean_html can do nothing with + # an empty string :) + if not text: + return u'' + return clean_html(MARKDOWN_INSTANCE.convert(text)) |