diff --git a/modules/system/system.module b/modules/system/system.module
index d0a542e..90b83dc 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -2706,6 +2706,15 @@ function system_system_info_alter(&$info, $file, $type) {
     $info['regions_hidden'][] = 'page_top';
     $info['regions_hidden'][] = 'page_bottom';
   }
+  $file_dir = dirname($file->uri);
+  if (empty($info['version']) && is_dir("$file_dir/.git")) {
+    // No need to initalize this variable because it is taken by reference.
+    exec("git --git-dir $file_dir/.git describe  --tags $(git  --git-dir $file_dir/.git rev-list --topo-order --max-count=1 HEAD) 2>&1", $last_tag);
+    $last_tag = $last_tag[0];
+    if (preg_match('/^(' . preg_quote(DRUPAL_CORE_COMPATIBILITY) . '-\d+\.\d+(?:-[^-]+)?)((-\d+-)g[0-9a-f]{7})?$/', $last_tag, $matches)) {
+      $info['version'] = isset($matches[2]) ? $matches[1] . $matches[3] . 'dev' : $last_tag;
+    }
+  }
 }
 
 /**
