Closed Dieterbe closed 2 years ago
maybe we should just document the shortcomings for the bash version, and defer to another program for more advanced/fewer edge cases. I'm sure they exist but i'll need to search around a bit.
https://github.com/cortesi/modd seems to work well in my tests, and in particular seems to handle both of the above cases as expected. I use this modd.conf:
** +noignore {
prep: /home/dieter/scripts/git-sync
}
Hi, nice catch! I guess the shortcomings should be addressed and documented, maybe @IvanMalison can whip something up?
I think most - but not all - cases could be catched by adding e.g. a one second delay before git scans for changes. What do you think?
To close this I propose to move both solutions to a new /contrib directory. If there are any concerns please speak up.
I don't think a delay will fix this. I recommend documenting the shortcomings until there is a fix. I don't plan to work on this as I switched to modd.
Yes, I'll document the shortcomings and move. Is your modd.conf still valid and are you OK with putting it under contrib?
I pushed the move to contrib/, please have a look.
As an aside, I think git-sync-on-inotify with GIT_SYNC_INTERVAL will be OK and in some cases better. I have documented the state of affairs so users can make an informed choice.
@IvanMalison you might also want to have a look!
Is your modd.conf still valid and are you OK with putting it under contrib?
yeah i still use the same config as i shared earlier. works fine for me. cheers!
Thanks for letting me know! BTW I dropped the noignore
as it was a bit of a foggy option to me.
1) notifywait prints the first file modified (example :
touch foo.1 foo.2
,$changedFile
will be "foo.1") so if you write to multiple files simultaneously, if the first file is in .gitignore, the git-sync will be skipped and the change to the other (non ignored files) will be "forgotten about". 2) any changes that happen in between two calls ofnotifywait
(e.g. while GIT_SYNC_COMMAND is running, or while the ignore check is running) are unnoticed and "forgotten about"the first issue can be solved by running
inotifywait -m
and processing all events - or leaving the gitignore related work up to GIT_SYNC_COMMAND.the second can be solved by running inotifywait without a timeout, so it catches everything, and concurrently - in another thread - implement the timeout (e.g. with a sleep) to periodically trigger the sync. But I'm not sure how to do this all in bash in a way that we don't concurrently run two syncs (one due to an inotifywait event and one due to a timeout), doing this in something like Go would make more sense... maybe we should just document the shortcomings for the bash version, and defer to another program for more advanced/fewer edge cases. I'm sure they exist but i'll need to search around a bit.