{"thread":{"id":"21694","subject":"Help creating script that mass-pulls Git(Hub) repos","startedAt":"2009-11-21T10:25:20Z","lastAt":"2009-11-21T15:18:22Z","messageCount":2,"participants":["Tony Maserati","Kumar Appaiah"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"128063","messageId":"dc191bcd0911210225k3cf946c6k54f1287c818af5a8@mail.gmail.com","threadId":"21694","inReplyTo":null,"subject":"Help creating script that mass-pulls Git(Hub) repos","fromName":"Tony Maserati","fromEmail":"abletony84@gmail.com","sentAt":"2009-11-21T10:25:20Z","receivedAt":"2009-11-21T10:25:20Z","isPatch":false,"sender":{"key":"abletony84@gmail.com","avatar":null},"body":"Hi,\n\nI got a bunch of repos I've cloned off GitHub and I'm looking for the\nbest way to keep them all up to date.\n\nI got a working zsh script, but it lacks some stuff. For instance I\nthink it'd be neat if it could output the difference between the\ncommit dates as oppose to those long hashes. And if it could initiate\nthe pull only when necessary. Other ideas are welcome.\n\nDoes anybody have any suggestions to how I might complete or otherwise\nimprove the below scripts? Thanks in advance.\n\nHere's the working version:\n\nabletony84$ cat pull_all.sh\n\n#!/usr/bin/env zsh\n\nfor folder in $PWD/**/.git(:h); do\n\n  cd $folder\n\n  git pull\n\ndone\n\n-\n\nThis script lacks a proper if clause, and shows hashes instead of dates:\n\nabletony84$ cat pull_all2.sh\n\n#!/usr/bin/env zsh\n\nfor folder in $PWD/**/.git(:h); do\n\n  cd $folder\n\n  if this repo needs an update; then # git ls-remote has been suggested\n\n    old=$(git rev-parse HEAD)\n\n    git pull >& /dev/null\n\n    new=$(git rev-parse HEAD)\n\n    echo \"$folder: $old -> $new\"\n\n  else\n\n    echo \"$folder: nothing to do\"\n\n  fi\n\ndone\n\n-\n\nA slightly different approach, even more incomplete than the previous:\n\nabletony84$ cat pull_all3.sh\n\n#!/usr/bin/env zsh\n\nfor folder in $PWD/**/.git(:h); do\n\n  cd $folder\n\n  if repo still exists at github; then\n\n    git fetch >& /dev/null\n\n    if a merge is needed; then\n\n      git merge >& /dev/null\n\n      echo \"$folder: date_of_last_current_commit -> date_of_last_new_comit\"\n\n    else\n\n      echo \"$folder: nothing to do\"\n\n    fi\n\n  fi\n\ndone\n\n-\n\nThanks again!\n\nTony\n"},{"id":"128067","messageId":"20091121151822.GA8155@bluemoon.alumni.iitm.ac.in","threadId":"21694","inReplyTo":"dc191bcd0911210225k3cf946c6k54f1287c818af5a8@mail.gmail.com","subject":"Re: Help creating script that mass-pulls Git(Hub) repos","fromName":"Kumar Appaiah","fromEmail":"a.kumar@alumni.iitm.ac.in","sentAt":"2009-11-21T15:18:22Z","receivedAt":"2009-11-21T15:18:22Z","isPatch":false,"sender":{"key":"a.kumar@alumni.iitm.ac.in","avatar":"https://gravatar.com/avatar/7ce299108bfff26792729bde4a1dd0638292f852a042d40a0a1991ff2ae58b0b?d=mp&s=160"},"body":"On Sat, Nov 21, 2009 at 11:25:20AM +0100, Tony Maserati wrote:\n> Hi,\n> \n> I got a bunch of repos I've cloned off GitHub and I'm looking for the\n> best way to keep them all up to date.\n\nWould mr help?\n\nhttp://kitenet.net/~joey/code/mr/\n\nKumar\n-- \nKumar Appaiah\n"}]}