Back to blogYouTube Video

Published December 28, 2025

Syncing projects with Google Drive - Part 18 (Connecting the new gitignore parser)

Can't play the video or having issues? Here's the direct link.

AI Summary

This video focuses on integrating a custom-built `.gitignore` parser into an existing project synchronization algorithm designed for Google Drive.

Key Takeaways

  • Integration: The primary goal is connecting the logic from the previous two videos (the custom parser) to the core sync engine.
  • Functionality: This ensures the synchronization process respects `.gitignore` rules, preventing unnecessary or sensitive files from being uploaded to Google Drive.

Description

Book a call: https://calendly.com/itshassanaziz/discuss-a-project ==== ==== ==== We spent the last couple videos building our own custom gitignore parser. In this video, we're finally going to connect it to our sync algorithm. Let's do this. :) ==== ==== ==== LINKS Website: https://www.hassandev.me Portfolio: https://www.hassandev.me/work YouTube: https://www.youtube.com/@itshassanaziz?sub_confirmation=1 My Book: https://www.hassandev.me/designing-websites X / Twitter: https://x.com/nothassanaziz

Transcript

Auto-generated transcript
Okay guys welcome back to the DriveSyncer project. In the previous video we built this should ignore function over here in the in the git ignore struct and this is basically going to tell us whether we can ignore a file or we should upload it or whatever right and now that we've written this function we are basically done with the new git ignore parser and now we can actually start to integrate it with our synchronizing algorithm over here. So as you can see there's already a couple of errors over here in this file because we're now using the list of git ignore patterns instead of using a list of strings. We're going to need to do a bit of refactoring over here to make this entire algorithm more compatible with our new ignore pattern struct. First thing I'm going to do is over here let's go and create a new variable called git ignore and here we will actually create our new git ignore struct. We'll pass in our folder, we'll pass in the global ignore which will be in .grb.config.ignore. We'll also pass in the readGitignore boolean which should be in our config over here and then we don't need any of this code anymore so we can just comment it out and over here in the countTotalFiles function we can pass in gitignore.toignore. Now this is a list of ignore patterns not a list of strings so we do need to refactor this function to accept a list of ignore patterns instead of strings. Now the first thing we need to do is up here create a list of parse ignores because we want to convert this into a list of strings We say make a list of strings with a capacity of zero or a length of zero but a capacity of the length of the to ignore list and then we just loop over the to ignore list and we'll say parse ignores dot append pattern dot pattern there we go and then over here in this for loop over here we'll just pass in parsed ignores instead of the to ignore list now instead of looping over the entire ignore list anymore what we can do is and also let's also pass in the git ignore struct over here as a pointer because we are going to need it and then instead of this entire loop over the ignore list what we can do is we can just say switch git ignore dot should ignore and pass in the path over here along with the dir entry as well and then let's say if this upload is allowed then we should just append total files right because we are going to upload this because the upload is allowed otherwise if the return type is ignored there we can just return file path dot skip there and if it is ignore file then we can just return nil and move on to the next path right and then we don't need any of this code either so we can just remove it completely and over here let's just add a default case like default return nil just so we satisfy the error and okay apparently that doesn work either so instead of this let just add a return nil outside over here and that should make that error go away And make sure to pass that in over here as such You know, one more thing that I just realized over here, if we're passing the entire get ignore struct over here, we don't need to pass in the ignore list separately, right? What we can do is we can remove this and go back over here and remove this to ignore from the arguments list because we're not even using it anymore, right? So back in the upload folder function now down here instead of this complicated ignore logic that we previously had all we can all we just need to say now is Get ignore dot should ignore passing the path pass into their entry and then just say case ignored their return file path dot skip their Case ignore file return new and just with those five or six lines of code. We have implemented the entire get ignore logic that we just built in the past two three whatever videos now before testing this out I'm going to go over to the upload file function I'm just going to comment out these logs just for now because I just want to see the logs of skipping files and folders right just so I know that it's actually working and we're going to have to replace this response variable with an underscore just so go stops complaining at me this is just for testing guys now let's see what happens if I actually run this with the new getignore logic okay so apparently we were using progress bars and not the actual logs so the logs should be in the log file over here let just go and look at them over here so these are all the logs for this current upload as you can see it pretty much skip most of the files over here yeah pretty much skipped almost every file over here except for the I guess the progress bar which was changed the log file which obviously got changed because we're running the program and it's outputting some logs the sync file which we literally just wrote code for it right here. Other than that it just skipped basically everything. So no extra file was uploaded over here. So yeah that's the new git ignore parser. It works and you can also put all sorts of complicated patterns over here right because we've actually added support for all of them over here. So yeah that works and I'm going to stop the video over there guys. Thank you for watching. Like, comment, subscribe. We've made a ton of progress in this project so if you're following along so far thank you and uh yeah we'll see what we build next time quick self promo plug this is my professional website and i'm a freelance developer who makes web and mobile apps for people if this is something you're interested in if you want to hire a developer to work on a project or if you know someone who wants to hire a developer to work on some project then go to the top link in the description and book a call with me it's completely free we'll talk about your project We'll see what's what and we'll start working together to make it a reality if that's something you're interested in top link in the description Other than that, thank you for watching the video and I'll see you in the next one

Share this article

All great things started with a conversation

If you've got a cool project or opportunity and you want me to be a part of it, set up a free meeting with me here, and let's talk. 😊