Add GCLIENT_DEP_REF env var for recurse command

The goal of this change is to facilitate analyzing DEPS autorolls https://crrev.com/c/2250928

Change-Id: Icbebd144a85f7e24aa638f93d8c30f3f0aab1e5c
Bug: 923016
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2239069
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Gregory Guterman <guterman@google.com>
diff --git a/gclient.py b/gclient.py
index 5acbfae..b3ee98f 100755
--- a/gclient.py
+++ b/gclient.py
@@ -986,6 +986,9 @@
         if self.url:
           env['GCLIENT_URL'] = str(self.url)
         env['GCLIENT_DEP_PATH'] = str(self.name)
+        parts = self.url.split('@')
+        if len(parts) > 1:
+          env['GCLIENT_DEP_REF'] = parts[-1]
         if options.prepend_dir and scm == 'git':
           print_stdout = False
           def filter_fn(line):
@@ -1020,9 +1023,13 @@
         elif os.path.isdir(cwd):
           try:
             gclient_utils.CheckCallAndFilter(
-                args, cwd=cwd, env=env, print_stdout=print_stdout,
+                args,
+                cwd=cwd,
+                env=env,
+                print_stdout=print_stdout,
                 filter_fn=filter_fn,
-                )
+                shell=True,
+            )
           except subprocess2.CalledProcessError:
             if not options.ignore:
               raise
@@ -2041,6 +2048,7 @@
   Runs a shell command on all entries.
   Sets GCLIENT_DEP_PATH environment variable as the dep's relative location to
   root directory of the checkout.
+  Sets GCLIENT_DEP_REF environment variable as the dep's ref if available
   """
   # Stop parsing at the first non-arg so that these go through to the command
   parser.disable_interspersed_args()