Pulling Git Repositories.

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Pulling Git Repositories. Tue Nov 28, 2017 10:38 am • by TimCoxon
Hi, Really loving Hazel but having issues with getting a rule running.
I've got the tricky parts sorted but it's a seemingly simple bit that I am having issues with.

I have a directory called Git which contains numerous repositories and subfolders of repositories. (repositories being a folder containing a hidden folder called ".git")

I am looking to go through all of these, run a shell script to check if they are up to date or not and pull from a remote if not.

I am aware that by default hazel doesn't read hidden files/folders (already sorted that with the default write thing).
I have tested the shell script aspect of this and that all works fine.

The thing I can't fathom is the hazel logic to implement checking a folder/sub folders for:
if current folder contains a folder called .git run rules.

Thoughts? Suggestions? All much appreciated
Tim
TimCoxon
 
Posts: 2
Joined: Tue Nov 28, 2017 10:29 am

Re: Pulling Git Repositories. Tue Nov 28, 2017 12:29 pm • by Mr_Noodle
Look up "nested conditions" in the help. With that you can do something like:
Code: Select all
If (all) are met
    If (all) are met for (any of its sub-files/folders)
        Name is .git


Alternatively, you can have a script in the conditions check for it.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Pulling Git Repositories. Tue Nov 28, 2017 3:46 pm • by TimCoxon
That was pretty much what I was using but the previews were failing. Just looked back at it and it has kinda worked.
Kinda being that it's matched all the first level folders that have a .git folder at any depth within them.

a being root folder
- being depths

a
*-b
--.git
*-c
--d
---.git

This is what it's currently doing.
Ideally, it would do this instead.

a
*-b
--.git
-c
*--d
---.git

Note the matches between c & d.
This way I could then just run a git pull on any matched folder and know that all my repositories are up to date.

((Excuse what could be terrible formating ;) ))
TimCoxon
 
Posts: 2
Joined: Tue Nov 28, 2017 10:29 am

Re: Pulling Git Repositories. Wed Nov 29, 2017 11:58 am • by Mr_Noodle
That nested condition does match anything below the folder, without distinguishing between being in the folder directly or one of its subfolders. In that case, it might be better to use a script in a condition to check for the .git folder.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Pulling Git Repositories. Sat Jan 20, 2018 7:36 pm • by nikivi
I have a similar question. I want Hazel to watch some .git folders and see if there is a pull available and if so pull latest changes.

I have no idea how to do this though. I can do the pull with `git pull` but when should I run this command?

I can't run this command on file change. I guess I have to add trigger as a shell script that periodically runs a command that checks if pull is available (If such commands exists, I searched and can't find it). But wouldn't that be expensive?

What would be a good solution to this? Thank you.
nikivi
 
Posts: 39
Joined: Tue Mar 08, 2016 10:04 am

Re: Pulling Git Repositories. Mon Jan 22, 2018 10:04 am • by Mr_Noodle
I guess you can try having it run at an interval, or you can use Current Time to schedule the rule for certain specific times of the day.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion