Skip to content

Commit

Permalink
Ignore spaces after items in "Needs:" and "Tags:" lists (#373)
Browse files Browse the repository at this point in the history
Co-authored-by: Sam Bishop <sbishop@mastercontrol.com>
Co-authored-by: kaklakariada <christoph@users.sourceforge.net>
  • Loading branch information
3 people authored Feb 2, 2024
1 parent 14da7cd commit 355f8b0
Show file tree
Hide file tree
Showing 15 changed files with 328 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,7 @@ else if (!this.name.equals(other.name))
{
return false;
}
if ((other.revision != REVISION_WILDCARD) && (this.revision != other.revision))
{
return false;
}
return true;
return (other.revision == REVISION_WILDCARD) || (this.revision == other.revision);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ else if (!this.otherLinkEnd.equals(other.otherLinkEnd))
{
return false;
}
if (this.status != other.status)
{
return false;
}
return true;
return this.status == other.status;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
import org.hamcrest.Matcher;
import org.hamcrest.collection.IsEmptyIterable;
import org.hamcrest.collection.IsIterableContainingInAnyOrder;
import org.itsallcode.matcher.config.ConfigurableMatcher;
import org.itsallcode.matcher.config.MatcherConfig;
import org.itsallcode.openfasttrace.api.core.SpecificationItemId;

import com.github.hamstercommunity.matcher.config.ConfigurableMatcher;
import com.github.hamstercommunity.matcher.config.MatcherConfig;

/**
* {@link Matcher} for {@link SpecificationItemId}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
import java.util.Collection;
import java.util.stream.StreamSupport;

import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.hamcrest.*;
import org.hamcrest.collection.IsEmptyIterable;
import org.hamcrest.collection.IsIterableContainingInAnyOrder;
import org.itsallcode.matcher.config.ConfigurableMatcher;
import org.itsallcode.matcher.config.MatcherConfig;
import org.itsallcode.openfasttrace.api.core.SpecificationItem;

import com.github.hamstercommunity.matcher.config.ConfigurableMatcher;
import com.github.hamstercommunity.matcher.config.MatcherConfig;

/**
* {@link Matcher} for {@link SpecificationItem}
*/
Expand Down
3 changes: 2 additions & 1 deletion doc/changes/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changes

* [3.7.2](changes_3.7.2.md)
* [3.7.1](changes_3.7.1.md)
* [3.7.0](changes_3.7.0.md)
* [3.6.0](changes_3.6.0.md)
Expand Down Expand Up @@ -37,4 +38,4 @@
* 0.4.0
* 0.3.0
* 0.2.0
* 0.1.0
* 0.1.0
11 changes: 11 additions & 0 deletions doc/changes/changes_3.7.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# OpenFastTrace 3.7.2, released 2024-??-??

Code name: Bugfixes for parsing `Needs` and `Tags` in Markdown

## Summary

This release fixes parsing of `Needs` and `Tags` entries in Markdown. OFT now ignores whitespace in both and also correctly parses `Tags` in beginning of a requirement item.

## Bugfixes

* #373: Ignore spaces after items in "Needs:" and "Tags:" lists (thanks to [@sambishop](https://github.com/sambishop) for his contribution!)
18 changes: 9 additions & 9 deletions doc/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,19 @@ Add the following to your `~/.m2/settings.xml`:
### Prepare the Release

1. Checkout the `main` branch.
1. Create a new "prepare-release" branch.
1. Update version in
* `openfasttrace-parent/pom.xml` (`revision` property)
* `README.md`
* `doc/developer_guide.md`
1. Add changes in new version to `CHANGELOG.md` and update the release date.
1. Verify that build runs successfully:
2. Create a new "prepare-release" branch.
3. Update version in
* `openfasttrace-parent/pom.xml` (`revision` property)
* `README.md`
* `doc/developer_guide.md`
4. Add changes in new version to `doc/changes/changes.md` and `doc/changes/changes_$VERSION.md` and update the release date.
5. Verify that build runs successfully:

```bash
mvn clean verify
```
1. Commit and push changes.
1. Create a new Pull Request, have it reviewed and merged.
6. Commit and push changes.
7. Create a new Pull Request, have it reviewed and merged.

### Perform the Release

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

import org.itsallcode.openfasttrace.api.core.ItemStatus;
import org.itsallcode.openfasttrace.api.core.SpecificationItemId;
import org.itsallcode.openfasttrace.api.importer.ImportEventListener;
import org.itsallcode.openfasttrace.api.importer.Importer;
import org.itsallcode.openfasttrace.api.importer.ImporterException;
import org.itsallcode.openfasttrace.api.importer.*;
import org.itsallcode.openfasttrace.api.importer.input.InputFile;

class MarkdownImporter implements Importer
Expand Down Expand Up @@ -42,10 +40,10 @@ class MarkdownImporter implements Importer
transition(SPEC_ITEM , DEPENDS , MdPattern.DEPENDS , () -> {} ),
transition(SPEC_ITEM , NEEDS , MdPattern.NEEDS_INT , this::addNeeds ),
transition(SPEC_ITEM , NEEDS , MdPattern.NEEDS , () -> {} ),
transition(SPEC_ITEM , DESCRIPTION, MdPattern.DESCRIPTION, this::beginDescription ),
transition(SPEC_ITEM , DESCRIPTION, MdPattern.NOT_EMPTY , this::beginDescription ),
transition(SPEC_ITEM , TAGS , MdPattern.TAGS_INT , this::addTag ),
transition(SPEC_ITEM , TAGS , MdPattern.TAGS , () -> {} ),
transition(SPEC_ITEM , DESCRIPTION, MdPattern.DESCRIPTION, this::beginDescription ),
transition(SPEC_ITEM , DESCRIPTION, MdPattern.NOT_EMPTY , this::beginDescription ),

transition(DESCRIPTION, SPEC_ITEM , MdPattern.ID , () -> {endDescription(); beginItem();} ),
transition(DESCRIPTION, TITLE , MdPattern.TITLE , () -> {endDescription(); endItem(); rememberTitle(); }),
Expand Down Expand Up @@ -301,9 +299,9 @@ private void addDependency()
private void addNeeds()
{
final String artifactTypes = this.stateMachine.getLastToken();
for (final String artifactType : artifactTypes.split(",\\s*"))
for (final String artifactType : artifactTypes.split(","))
{
this.listener.addNeededArtifactType(artifactType);
this.listener.addNeededArtifactType(artifactType.trim());
}
}

Expand All @@ -326,9 +324,9 @@ private void addCoverage()
private void addTag()
{
final String tags = this.stateMachine.getLastToken();
for (final String tag : tags.split(",\\s*"))
for (final String tag : tags.split(","))
{
this.listener.addTag(tag);
this.listener.addTag(tag.trim());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum MdPattern
+ SpecificationItemId.ID_PATTERN
+ ").*?"),
ID("`?((?:" + SpecificationItemId.ID_PATTERN + ")|(?:" + SpecificationItemId.LEGACY_ID_PATTERN + "))`?.*"),
NEEDS_INT("Needs:\\s*(\\w+(?:,\\s*\\w+)*)"),
NEEDS_INT("Needs:(\\s*\\w+\\s*(?:,\\s*\\w+\\s*)*)"),
NEEDS("Needs:\\s*"),
NEEDS_REF(PatternConstants.UP_TO_3_WHITESPACES + PatternConstants.BULLETS
+ "(?:.*\\W)?" //
Expand All @@ -46,7 +46,7 @@ enum MdPattern
NOT_EMPTY("([^\n\r]+)"),
RATIONALE("Rationale:\\s*"),
STATUS("Status:\\s*(approved|proposed|draft)\\s*"),
TAGS_INT("Tags:\\s*(\\w+(?:,\\s*\\w+)*)"),
TAGS_INT("Tags:(\\s*\\w+\\s*(?:,\\s*\\w+\\s*)*)"),
TAGS("Tags:\\s*"),
TAG_ENTRY(PatternConstants.UP_TO_3_WHITESPACES + PatternConstants.BULLETS
+ "\\s*" //
Expand Down
Loading

0 comments on commit 355f8b0

Please # to comment.