johnmehr / gitup

A minimalist, dependency-free FreeBSD program to clone/pull Git repositories.
BSD 2-Clause "Simplified" License
50 stars 9 forks source link

Make repair scriptable #78

Closed michael-o closed 2 years ago

michael-o commented 2 years ago

I'd like to automate gitup, but this is a problem:

https://github.com/johnmehr/gitup/blob/aad38a82b254e461bd6337ce72bfe7f2bf6b4d13/gitup.c#L4131-L4134

Basically, the return code is still zero althrough I need to rerun gitup. From a script (periodic(8)) I cannot detect that w/o grepping through the output which I don't want to.

My request is to either return another, well defined, exit code or make it configurable to return non-zero for that.

johnmehr commented 2 years ago

I just added code to return a value of 2 if a repair occurs. How does it work for you now?

michael-o commented 2 years ago

I just added code to return a value of 2 if a repair occurs. How does it work for you now?

Yes, this works for me, but should also be reflected in the manpage:

+ [ -z ports ]
+ /usr/local/sbin/gitup -v 0 ports
# The local repository has been repaired.  Please rerun gitup to pull the latest commit.
+ rc=2
+ [ 2 -eq 2 ]
+ /usr/local/sbin/gitup -v 0 ports
+ rc=0
+ [ 0 -ne 0 ]
+ exit 0
johnmehr commented 2 years ago

Gah! Sorry about that!

michael-o commented 2 years ago

Looks good to me.