-
Notifications
You must be signed in to change notification settings - Fork 73
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
Easier-to-parse diff #221
Comments
This is not easy to do, because the diff is done at the lowest level of filters, where all the fields are simple strings. This allows for easy comparison with whatever is currently set in Gmail, without having to parse and back-translate upstream filters to higher level representations. The line you report ( |
Yep, my process definitely started with "I'll just send a pull request" and quickly turned into "this is nontrivial and should be a feature request". |
Is there a reasonable place to say "here are all the filters before, here are all the filters after, throw it at |
Alright, I found a place and ran it, lutzky@f3264ab. The output doesn't look great. |
Yeah indeed. It's a bunch of strings not very different from what's existing. To make it better you really need a parser for Gmail filter expressions. |
Yep. Now, even if I were to write such a parser, the output for main.FilterNode{
And: []main.FilterNode{
{
And: nil,
Or: []main.FilterNode{
{From: "person1"},
{From: "person2"},
- {From: "person3"},
{From: "person4"},
},
Not: nil,
From: "",
},
{
And: nil,
Or: nil,
Not: &main.FilterNode{
And: nil,
Or: []main.FilterNode{
{From: "person5"},
{
And: nil,
Or: nil,
Not: nil,
- From: "person6",
+ From: "person7",
},
},
Not: nil,
From: "",
},
From: "",
},
},
Or: nil,
Not: nil,
From: "",
} Even if we hide all the before: {person1 person2 person3 person4} -{person5 person6}
after: {person1 person2 person4} -{person5 person7}
diff:
{
person1
person2
- person3
person4
}
-{
person5
- person6
+ person7
} So, essentially, it's a matter of adding newlines and indentation in a few places, and running a traditional diff. I'll see if I can mock something up. |
It's quick-and-dirty, but perhaps not entirely useless: https://go.dev/play/p/EREXFY8gTwR |
It's certainly a start. There are a lot more cases to consider though. From the top of my head:
And combinations of those. |
This issue is stale because it has been open for 30 days without activity. |
Tweaked it a bit to handle your example cases: https://go.dev/play/p/qNFzmtFEWCo WDYT? |
Cool! I tried a couple more nasty cases (colons outside operators) and the results still seem good! https://go.dev/play/p/LtIy47e5eY7. |
Makes for easier-to-read diffs. mbrt#221
Makes for easier-to-read diffs. mbrt#221
Makes for easier-to-read diffs. mbrt#221
Makes for easier-to-read diffs. mbrt#221
Currently gmailctl diff can sometimes show output like this:
...it's not fun figuring out what's missing there.
The cmp package does what I mean, I think: https://go.dev/play/p/E5RwmDYIsvX -
The text was updated successfully, but these errors were encountered: