diff --git a/src/somef/regular_expressions.py b/src/somef/regular_expressions.py index 5157c147..7055d009 100644 --- a/src/somef/regular_expressions.py +++ b/src/somef/regular_expressions.py @@ -198,8 +198,13 @@ def extract_repo_status(unfiltered_text, repository_metadata: Result, readme_sou if init > 0: end = unfiltered_text.find("](", init) repo_status = unfiltered_text[init + 3:end] - repo_status = repo_status.replace("Project Status: ", "") - short_status = repo_status[0:repo_status.find(" ")].lower() + # repo_status = repo_status.replace("Project Status: ", "") + # short_status = repo_status[0:repo_status.find(" ")].lower() + + status_value = repo_status.replace("Project Status:", "").strip() + parts = re.split(r'[ \]]', status_value) + short_status = parts[0].lower() + repository_metadata.add_result(constants.CAT_STATUS, { constants.PROP_TYPE: constants.URL, diff --git a/src/somef/test/test_data/repostatus-README-2.md b/src/somef/test/test_data/repostatus-README-2.md new file mode 100644 index 00000000..9dea12f7 --- /dev/null +++ b/src/somef/test/test_data/repostatus-README-2.md @@ -0,0 +1,50 @@ +repostatus.org +============== + +[![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) + +A standard to easily communicate to humans and machines the development/support and usability status of software repositories/projects. + +For the majority of documentation and human-readable text, see https://www.repostatus.org/ or the [gh-pages branch](https://github.com/jantman/repostatus.org/tree/gh-pages) from which it is built. + +Please feel free to leave comments as Issues, or open pull requests. + +Community Involvement +--------------------- + +This project seems to have gained a lot more interest than I thought it would. As of April, 2017 there are [over 1,200 references on GitHub](https://github.com/search?l=&q=http%3A%2F%2Fwww.repostatus.org%2Fbadges%2F+-user%3A%22jantman%22&ref=advsearch&type=Code&utf8=%E2%9C%93) +to repostatus.org badge URLs. I do *not* want to be the sole person making decisions for this project. I encourage everyone who finds +it useful to watch [the repo on GitHub](https://github.com/jantman/repostatus.org) and provide their feedback in discussions, especially the +issues with the [discussion](https://github.com/jantman/repostatus.org/issues?q=is%3Aopen+is%3Aissue+label%3Adiscussion) or +["needs decision"](https://github.com/jantman/repostatus.org/issues?q=is%3Aopen+is%3Aissue+label%3Adiscussion+label%3A%22needs+decision%22) +labels. I'm handling the code updates, but I very much want this project to be driven based on consensus of those who use it. + +Contributing +------------ + +For changes to the site, text, or anything other than the badges themselves (and their descriptions and sample markup), +simply cut a pull request against the master branch. The content that appears on the website (in the gh-pages branch) +comes from ``gh_pages/`` in master. Note that some of it (described below) is generated programmatically. + +The badges (SVG), their descriptions and their sample markup are generated by a [Fabfile](http://www.fabfile.org/). If you're looking +to add a new badge or make changes to an existing one, update the ``badge_info`` dictionary at the top of ``fabfile.py`` and +then run ``fab make-badges`` (requires Python and some packages; see the comment at the top of the file for requirements). This will +regenerate all badges, metadata and samples into ``badges/latest``. You can then cut a pull request for this; a version number will +be assigned at merge time. Please remember to also update ``gh_pages/index.md`` for any badge changes. + +Release Process +--------------- + +1. Get everything included in the release merged into master. +2. Assign a version number. In general, patch versions should only be assigned for releases that fix trivial (i.e. spelling) +issues or touch things other than the badges and JSON (i.e. the markup samples). Minor versions should be assigned to +changes that correct grammatical or spelling errors, or graphical elements. Major versions must be assigned to any changes +that add or remove badges, or alter the meaning of existing badges. +3. Re-run ``fab make-badges`` and ensure there are no new changes. +4. Run ``fab version-badges x.y.z`` (where ``x.y.z`` is the version number). +5. Add a ``CHANGELOG.md`` entry. +6. Run ``fab badges2pages`` to copy the badges under ``gh-pages/`` +6. Run ``fab publish`` to push changes to the gh-pages branch. +7. Review the diff of gh-pages against origin. +8. Assuing all is well, push gh-pages to origin. The changes are now live. +9. Tag master with the version number (use GitHub Releases) diff --git a/src/somef/test/test_regular_expressions.py b/src/somef/test/test_regular_expressions.py index f64bad98..410ca691 100644 --- a/src/somef/test/test_regular_expressions.py +++ b/src/somef/test/test_regular_expressions.py @@ -572,3 +572,19 @@ def test_issue_904(self): assert expected_doc_url in documentation_values, ( f"Expected documentation url {expected_doc_url} not found in {documentation_values}" ) + + + def test_issue_985(self): + """Test to ensure extract_repo_status are extracted correctly.""" + + with open(test_data_path + "repostatus-README-2.md", "r") as data_file: + test_text = data_file.read() + repo_status = regular_expressions.extract_repo_status(test_text, Result(), + test_data_path + "repostatus-README-2.md") + status = repo_status.results[constants.CAT_STATUS] + + assert len(status) == 1, f"Should be 1 status, but got {len(status)}" + extracted_url = status[0]['result']['value'] + expected_url = "https://www.repostatus.org/#active" + + assert extracted_url == expected_url, f"Expected {expected_url}, but got {extracted_url}" \ No newline at end of file