Refactor AsyncTags
Hi @extrawurst, I thought it would be a good idea to push my preliminary solution because I have some questions.
- ~~I looked at the other 2 implementations of AsyncSingleJob, do you think the solution is the right direction?~~
- ~~Why is there a 3 second timer in the current get-tag code? It seems interlinked with the async code, but it doesn't appear in the AsyncSingleJob struct. Is it still needed?~~
- ~~It seems there is a regression that removes the commit messages in the tags list, is that on purpose? does it need fixing? can I fix it directly in this PR? (introduced with 0f896933) - ah, it seems an issue with tui or crossterm (maybe broken API?)~~
Implementation
- It took some effort, and it probably is very much obvious that my previous rust experience is close to 0, but I think I have build an (at least functional) refactor.
- I wanted to preserve the "unchanged" notification functionality used in AsyncTags, so I moved it over to AsyncJob
Review
@extrawurst, can you perform a review and give me some guidance on what parts to improve?
Documentation
This Pull Request fixes/closes #757.
It changes the following:
- Refactor AsyncTags to AsyncTagsJob
- ~~(Fix regression: missing commit messages in TagList?)~~
I followed the checklist:
- n/a - refactor
- [x] I ran
make checkwithout errors - [x] I tested the overall application
- [x] I added an appropriate item to the changelog
Hi @mvaneijk sorry for making you digg into this without having checked deeper myself. turns out the asyncjob abstraction was not good ending yet to allow you to do this in a nice way.
I pushed a few additions now:
- run now returns a notification value we want to be sent out when the job finished, this way you can customise depending on
notify - run takes a
RunParamstype as a param now which allows us to send intermediate updates out (this is needed to do stuff like the push/pull progress bar) (see in action here: https://github.com/extrawurst/gitui/issues/889#issuecomment-911879771)
I think this should provide everything you need.
For the is_outdated and force stuff you can write a simple wrapper around AsyncSingleJob<YouTagsJob> that uses take_last, stores the last result and uses it to always be able to check whether the last result is outdated. I hope I make sense :D
Hi @extrawurst, thanks for the effort. No worries, this is a good exercise for me to get acquainted with Rust.
Regarding the 'simple' wrapper. I will think of something. But I guess I probably end up creating another AsyncSingleJob for this wrapper/awaiter, because it can only compare the last_job hash after the tagsjob has finished. And the wrapper cannot be blocking while awaiting the result, hence should be an AsyncJob.
hi @extrawurst, I don't know how to perform the hashcheck without changing the AsyncSingleJob code.
Situation
- What is needed, is a function that
- performs the hash of the result upon completion of the
get_tagsfunction. - compares the hash to the last result stored in the queue
- sends the appropriate notification according to the hash comparison
- performs the hash of the result upon completion of the
- However, this function cannot be part of the AsyncJob, since the AsyncJob knows nothing about other AsyncJobs in the queue
- This function cannot be part of a synchronous wrapper, because it has to wait on the AsyncJob result before running the hash function, and we don't want it to block.
- This function cannot be part of an asynchronous wrapper (instantiating another AsyncSingleJob queue, because previous three points will recursively apply on the new instance.
I think there are 2 options
- Make it possible to run a function at AsyncSingleJob scope upon completion of the AsyncJob
- Make the
last_resultavailable for the current running AsyncJob.
Both need changing of the AsyncSingleJob code, what do you think?
~ edit: after some rethink, I guess option 1 makes the most sense. Probably a "send_notification" function as part of the AsyncJob trait that gets access to last_result. Sounds like a combination of the two :)
The eagle has landed
I guess I've seen the light :)
@extrawurst, can you review it?
The eagle has landed
I guess I've seen the light :)
haha that sounds great! ❤️
@extrawurst, can you review it?
I will, as soon as I am back from my vacation!
I checked out the branch and played around in it and noticed the tags are not showing anymore in the log tab:
master:

Good catch, I will look into it.
@mvaneijk are you still on this?
I will try again today and let you know if I give up after that. I have a hard time debugging the issue,
@extrawurst feel free to assign someone else to it. Maybe part or my PR can be reused, I feel that it is something small but I will probably have time again in the Christmas Holidays.
putting into draft until picked up again
This issue has been automatically marked as stale because it has not had any activity half a year. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.