Closed srenatus closed 1 month ago
Hi @srenatus :wave:
Thanks for taking an interest in ad
! I think I know the issue that you are hitting and I suspect it's not related to current develop. Are you seeing this behaviour when just opening ad
without any files and trying to check the git log of the repo you are in? As in:
ad
with no args on the command line!git log --oneline<CR>
in NORMAL modeI think that if you try that but instead open a file or directory within the repo as the first step then it should work? It does for me at least.
If I'm right then I know what the problem is: the default output buffer doesn't have a directory associated with it, so it doesn't pass one through in the plumbing message :facepalm: The fix should be simple enough: I just need to associate the default output buffer with the current working directory of the editor.
Sorry I should have provided those repro steps instead of letting you figure it out. But what you've described is exactly what I had tried. Thanks for the quick fix, I'll try it in a moment
Yay the unmodified plumbing.rules now work for showing git infos ✔️
Sp my immediate problem is resolved. 🥳
Fantastic :smile:
As for your question of debugging plumbing rules, I'm afraid I don't have a great answer for you at the moment. One thing that might be useful to do at some point is provide a way of running a plumbing message through the rules and showing how it is handled, but exactly how that would work inside of the editor I'm not sure yet.
💭 What does plumber do? 😅 I suppose plumber could just log something because it's an extra process.
that's a point actually, ad
has an internal log you can view (Alt + -
) and you can drop the logging level down to something more verbose like trace or debug using AD_LOG=debug ad ...
so if you don't mind reading logs that could work?
That sounds like a nice clean solution!
@srenatus that latest commit should give you some logs like the following when you run ad
using AD_LOG=debug ad $file
:
2024-10-10T06:48:34.609957Z DEBUG plumbing message: PlumbingMessage { src: Some("ad"), dst: None, wdir: Some("/home/sminez/repos/personal/ad"), attrs: {}, data: "19f6a61" }
2024-10-10T06:48:34.609970Z DEBUG checking rule 0
2024-10-10T06:48:34.609972Z DEBUG attempting to match Matches(Data, Regex { prog: [Inst { op: Split(3, 1), gen: 0 }, Inst { op: Comp(TrueAny), gen: 0 }, Inst { op: Split(3, 1), gen: 0 }, Inst { op: Save(0), gen: 0 }, Inst { op: Comp(Class(CharClass { negated: false, chars: [], ranges: [('a', 'f'), ('0', '9')] })), gen: 0 }, Inst { op: Comp(Class(CharClass { negated: false, chars: [], ranges: [('a', 'f'), ('0', '9')] })), gen: 0 }, Inst { op: Comp(Class(CharClass { negated: false, chars: [], ranges: [('a', 'f'), ('0', '9')] })), gen: 0 }, Inst { op: Comp(Class(CharClass { negated: false, chars: [], ranges: [('a', 'f'), ('0', '9')] })), gen: 0 }, Inst { op: Comp(Class(CharClass { negated: false, chars: [], ranges: [('a', 'f'), ('0', '9')] })), gen: 0 }, Inst { op: Comp(Class(CharClass { negated: false, chars: [], ranges: [('a', 'f'), ('0', '9')] })), gen: 0 }, Inst { op: Split(9, 11), gen: 0 }, Inst { op: Save(1), gen: 0 }, Inst { op: Match, gen: 0 }], submatch_names: [], clist: [Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }], nlist: [Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }, Thread { pc: 0, assertion: None, sm: 0 }], sms: [SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, SubMatches { refs: 0, inner: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }], free_sms: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], track_submatches: true, gen: 0, p: 0, prev: None, next: None })
2024-10-10T06:48:34.609993Z DEBUG matched: updating vars
2024-10-10T06:48:34.609997Z DEBUG attempting to match DataFrom("git -C $wdir show $0")
2024-10-10T06:48:34.609998Z DEBUG running "git -C $wdir show $0" to set message data
2024-10-10T06:48:34.615017Z DEBUG attempting to match AddAttrs({"action": "showdata", "filename": "/git/$0"})
2024-10-10T06:48:34.615022Z DEBUG adding attrs: {"action": "showdata", "filename": "/git/$0"}
2024-10-10T06:48:34.615030Z DEBUG rule matched
I'm not sure how helpful the debug logging of the patterns is given that the debug repr can be quite verbose (especially for regex!) so I think I'm actually going to tweak that a bit.
here we go, this is a little nicer to read:
2024-10-10T06:58:42.220479Z DEBUG plumbing message: PlumbingMessage { src: Some("ad"), dst: None, wdir: Some("/home/sminez/repos/personal/ad"), attrs: {}, data: "b24cfed" }
2024-10-10T06:58:42.220537Z DEBUG checking rule 0
2024-10-10T06:58:42.220571Z DEBUG checking matches pattern
2024-10-10T06:58:42.220587Z DEBUG regex match against data
2024-10-10T06:58:42.220639Z DEBUG matched: updating vars
2024-10-10T06:58:42.220653Z DEBUG checking data-from pattern
2024-10-10T06:58:42.220661Z DEBUG running "git -C $wdir show $0" to set message data
2024-10-10T06:58:42.225497Z DEBUG checking add-attrs pattern
2024-10-10T06:58:42.225526Z DEBUG adding attrs: {"action": "showdata", "filename": "/git/$0"}
2024-10-10T06:58:42.225556Z DEBUG rule matched
Just tried it. It's very nice. Thanks for your quick help 👏 I'll close this.
Hello! First off, thanks for
ad
, it's seems to be (or become) exactly what I have been looking for. ✨ ❤️I've stumbled upon a problem with a build from
develop
as of today, 830a9aff3ca5b1bd89e54b6c151d6bc02dd60d3c: It seems that plumbing git shas doesn't work. Changing the rule tofilename=git/$wdir/$0
, and also playing withdata set " ... "
, it seems like$wdir
is unset. How could I help debug this?For now, I've changed my plumbing rule to omit the
-C $wdir
ingit show
.