-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation, diff table headers, implement #324, and refactor logic into function #325
Open
Sternbach-Software
wants to merge
7
commits into
elliotchance:master
Choose a base branch
from
Sternbach-Software:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6aaa49e
Fix serious mistake in documentation
Sternbach-Software aa77bab
Add diff table headers
Sternbach-Software 4b3b8c2
Refactor DiffRow creation logic into DiffPage.getRow()
Sternbach-Software f4eae94
Add clarifying inline comments
Sternbach-Software b7daf5c
Add check for ancestry sources, fixing #324
Sternbach-Software 1c27a5d
Remove tabs in node_diff.go
Sternbach-Software d2dc486
1. Add ancestry-source-matching flag to toggle whether to perform tha…
Sternbach-Software File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,51 @@ func TestSimpleNode_Equals(t *testing.T) { | |
} | ||
} | ||
|
||
func TestAncestryNode_Equals(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: This test name implies that there is a type called func TestSimpleNode_Equals(t *testing.T) {
// ...
t.Run("AncestryNode", func(t *testing.T) {
//test when source ids are the same
original := GetAncestryIndividual("@S291470533@", "@S291470520@", "@S291470520@", "@S291470520@", "@S291470520@")
assert.True(t, gedcom.DeepEqualNodes(gedcom.newDocumentFromString(original).Nodes(), gedcom.newDocumentFromString(original).Nodes()))
//test when source ids are different, but _apid stays the same
left := gedcom.newDocumentFromString(GetAncestryIndividual("@S222222222@", "@S444444444@", "@S666666666@", "@S888888888@", "@S111111111@"))
right := gedcom.newDocumentFromString(GetAncestryIndividual("@S333333333@", "@S555555555@", "@S777777777@", "@S999999999@", "@S000000000@"))
assert.True(t, gedcom.DeepEqualNodes(left.Nodes(), right.Nodes()))
})
} |
||
//test when source ids are the same | ||
original := GetAncestryIndividual("@S291470533@", "@S291470520@", "@S291470520@", "@S291470520@", "@S291470520@") | ||
assert.True(t, gedcom.DeepEqualNodes(gedcom.newDocumentFromString(original).Nodes(), gedcom.newDocumentFromString(original).Nodes())) | ||
|
||
//test when source ids are different, but _apid stays the same | ||
left := gedcom.newDocumentFromString(GetAncestryIndividual("@S222222222@", "@S444444444@", "@S666666666@", "@S888888888@", "@S111111111@")) | ||
right := gedcom.newDocumentFromString(GetAncestryIndividual("@S333333333@", "@S555555555@", "@S777777777@", "@S999999999@", "@S000000000@")) | ||
assert.True(t, gedcom.DeepEqualNodes(left.Nodes(), right.Nodes())) | ||
} | ||
|
||
// This is an actual gedcom entry, hope that's ok. | ||
func GetAncestryIndividual(source1 string, source2 string, source3 string, source4 string, source5 string) string { | ||
return "0 @I152151456706@ INDI" + | ||
"\n1 NAME Jacob /Yourow/" + | ||
"\n2 GIVN Jacob" + | ||
"\n2 SURN Yourow" + | ||
"\n2 SOUR " + source1 + | ||
"\n3 PAGE New York City Municipal Archives; New York, New York; Borough: Manhattan; Volume Number: 13" + | ||
"\n3 _APID 1,61406::6159341" + | ||
"\n2 SOUR " + source2 + | ||
"\n3 PAGE Year: 1930; Census Place: Bronx, Bronx, New York; Page: 42A; Enumeration District: 0430; FHL microfilm: 2341213" + | ||
"\n3 _APID 1,6224::30826480" + | ||
"\n1 SEX M" + | ||
"\n1 FAMS @F89@" + | ||
"\n1 BIRT" + | ||
"\n2 DATE abt 1888" + | ||
"\n2 PLAC Russia" + | ||
"\n2 SOUR " + source3 + | ||
"\n3 PAGE Year: 1930; Census Place: Bronx, Bronx, New York; Page: 42A; Enumeration District: 0430; FHL microfilm: 2341213" + | ||
"\n3 _APID 1,6224::30826480" + | ||
"\n1 EVEN" + | ||
"\n2 TYPE Arrival" + | ||
"\n2 DATE 1905" + | ||
"\n2 SOUR " + source4 + | ||
"\n3 PAGE Year: 1930; Census Place: Bronx, Bronx, New York; Page: 42A; Enumeration District: 0430; FHL microfilm: 2341213" + | ||
"\n3 _APID 1,6224::30826480" + | ||
"\n1 RESI Marital Status: Married; Relation to Head: Head" + | ||
"\n2 DATE 1930" + | ||
"\n2 PLAC Bronx, Bronx, New York, USA" + | ||
"\n2 SOUR " + source5 + | ||
"\n3 PAGE Year: 1930; Census Place: Bronx, Bronx, New York; Page: 42A; Enumeration District: 0430; FHL microfilm: 2341213" + | ||
"\n3 _APID 1,6224::30826480" | ||
} | ||
|
||
func TestSimpleNode_Tag(t *testing.T) { | ||
Tag := tf.Function(t, (*gedcom.SimpleNode).Tag) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot lookup flags like this. While this might work when using it through the CLI, this can also be used a library. It's also just a leaky abstraction to write it this way. You have three choices:
FilterFunction
(gedcom/filter.go
Line 36 in 9061dca
SimpleNode.Equals
only will only apply to nodes that do not have a custom type with anEquals
method of their own. This is an important consideration because this is generic logic that you may want to apply to all nodes on top of any logic.If you want this to apply globally (and be controlled from the CLI) you might find it easier to do preprocessing first instead. That is, based on a CLI flag, you preprocess the files so when the comparison happens the logic has already been normalized.
We do in this already using FilterFunctions. For example the
-only-official
CLI flag (https://github.com/elliotchance/gedcom/blob/master/filter_flags.go#L57-L58) triggers the files to remove non-official GEDCOM tags so they don't exist for the comparison:gedcom/filter.go
Line 143 in 9061dca