Git updater shell script - Programming On Unix
Users browsing this thread: 5 Guest(s)
|
|||
I have mentioned a couple of times that I refuse to use Git for versioning my files. Yet, I sometimes need to compile something which resides in a Git repository, usually from GitHub. I keep those repositories in $HOME/github and (randomly) other folders below $HOME. Keeping them updated is relatively annoying though, so I automatized it.
You might want to modify $BLACKLIST and $GITDIRS, especially if you don’t use the bosh for scripting and/or you keep your repositories elsewhere. (On standard POSIX shells, $GITDIRS won’t work like this. Sorry. I might rewrite that line some day.) Usage: ./gitup.sh. Code: #!/opt/schily/bin/bosh Enjoy. Or modify as you need. -- <mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen |
|||
|
|||
That's a very useful script and could easily be adapted to anything other than HOME (well you could just as well use HOME=yourdir ./script too).
Aside: Your shell script writing script are the cleanest I've seen—this is very readable, which is not something I'd say of a lot of shell scripts I've read over the years. |
|||
|
|||
HOME=something stops working if you have no single place for your repos. But I did not want to overdo it with configuration parameters. I wrote this for myself and did not intend to share it initially.
And I actually prefer to understand what the hell I was thinking, so writing readable code makes sense to me ... ;-) Admittedly, sh makes it relatively easy to write a horrible mess of a code. One of the reasons why I resort to other languages for more complicated tasks, e.g. those which require interactive user input. -- <mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen |
|||
|
|||
I updated the initial post, adding a log to the git pull branch:
Code: git log $LOCAL..$REMOTE --date=short --pretty=format:" - New [%ad] : %s“ I noticed that I, sometimes, want to know what has changed. Results: Code: % ./gitup.sh I have noticed that it takes a while to process 14 repositories. I consider a rewrite in an actual programming language - shell scripts don’t work well with threads. (I tried playing with the parallel command, but it makes the code hard to read.) -- <mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen |
|||
|
|||
Looks useful!
Along a simlar vein is gita which keeps a list of your local git folders and can perform tasks on all of them, much like you do. I assume gita would have good error handling -- for example, if you want to pull all of your repos, but one of them needs merging or something. Although I guess this isn't a problem you have, if you only have the clones around for use rather than development. |
|||
|
|||
I use my script only for repositories which I use (= tools in my $PATH).
gita seems useful as well, but I could imagine that, given that it is mostly written in Python, its performance is even worse than mine. -- <mort> choosing a terrible license just to be spiteful towards others is possibly the most tux0r thing I've ever seen |
|||
|
|||
Yeah, very possible.
|
|||
|
|||
I did ~/local for all my xdg dirs, so ~/local/cfg was under git revision, it was entirely painless. Suggestions if you do: gitignore *, and git add -f whatever
|
|||