Not sure if this has been implemented. This would allow users to perform a git pull to the drush target

Command:
drush @mysite.remoteserver gp

Desired outcome:
Would perform a git pull from target site

Patch coming...

Comments

greg.1.anderson’s picture

You might want to take a look at the Drush ssh command. What you want could nearly be done via:

drush @mysite.remoteserver ssh git pull

I say nearly because the Drush ssh command does not cd to the Drupal site root before running the requested command. If it did this, then I think that would be preferable to a custom command that did just a git pull.

You might also want to take a look at the file example/example.bashrc, which defines a function 'gitd' that is supposed to allow command such as:

gitd @mysite.remoteserver pull

This presently is not working, although the following workaround is:

drush @mysite.remoteserver ssh "cd /path/to/drupal/root; git pull"

The manual 'cd' is awkward, of course. I think it would be helpful to make the Drush ssh command insert the 'cd' at the head of the user command automatically. A patch that did this would be welcome in the Drush issue queue.

chrisjlee’s picture

Interesting. Thanks greg, as always for the quick response. You've outlined some interesting flaws with my current theorized approach.

Nonetheless, you've given me some insight on how it could be achieved. I'll still attempt a different patch nonetheless.

greg.1.anderson’s picture

I wouldn't call them 'flaws'. It is perhaps a limitation to create a Drush command that will only execute a single git command ("pull"), but a remote git pull is still useful.

I fixed the 'gitd' command, so gitd @remote pull now works; the working version is now checked in to HEAD of Drush 8.x-6.x. The correct function looks like this:

function gitd() {
  s="$1"
  if [ -n "$s" ] && [ ${s:0:1} == "@" ] || [ ${s:0:1} == "%" ]
  then
    d="$(drush drupal-directory $s 2>/dev/null)"
    $(drush sa ${s%%:*} --component=remote-host > /dev/null 2>&1)
    if [ $? == 0 ]
    then
      drush ${s%%:*} ssh "cd '$d' ; git ${@:2}"
    else
      echo cd "$d" \; git "${@:2}"
      (
        cd "$d"
        "git" "${@:2}"
      )
    fi
  else
    "git" "$@"
  fi
}
chrisjlee’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pere orga’s picture

Project: Drush extras » Drush
Version: 7.x-1.x-dev » 8.x-6.x-dev
Component: Code » Core Commands
Status: Closed (fixed) » Active

I think this is about Drush and not Drush extras.

Sorry to reopen, but could this feature be extended to make easier pulling a contributed module?

See http://drupal.stackexchange.com/q/62934/10086

greg.1.anderson’s picture

Status: Active » Fixed

In 8.x-6.x-dev, the ssh command now automatically cd's to the Drupal root of the target, so you can now do this:

drush @site ssh git pull

Perhaps this can be considered fixed? If not, please be more specific with request. It is unlikely that we will do anything as specific as the example quoted in #6 in Drush core. Note also that this issue is originally about git pull, whereas the Stack Exchange question is about git clone.

pere orga’s picture

Ok, makes sense.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

updated issue summary