   getHostedGitInfo: (name) ->
     hostedGitInfo.fromUrl(name)
 
-  installGitPackage: (gitPackageInfo, options, callback) ->
+  installGitPackage: (packageUrl, gitPackageInfo, options, callback) ->
+    tasks = []
+
     cloneDir = temp.mkdirSync("atom-git-package-clone-")
-    tasks = []
-
-    tasks.push (cb) => @cloneGitPackage gitPackageInfo, cloneDir, cb
-    tasks.push (cb) => @installGitPackageDependencies(cloneDir, options, cb)
-    tasks.push ({name}, cb) =>
-      targetDir = path.join(@atomGitPackagesDirectory, name)
-      fs.cp cloneDir, targetDir, cb
-
-    async.waterfall tasks, callback
+
+    tasks.push (data, next) =>
+      @cloneGitPackage gitPackageInfo, cloneDir, (err) ->
+        next(err, data)
+
+    tasks.push (data, next) =>
+      console.log()
+      @installGitPackageDependencies cloneDir, options, (err) ->
+        next(err, data)
+
+    tasks.push (data, next) =>
+      @getRepositoryHeadSha cloneDir, (err, sha) ->
+        data.sha = sha
+        next(err, data)
+
+    tasks.push (data, next) ->
+      metadataFilePath = CSON.resolve(path.join(cloneDir, 'package'))
+      CSON.readFile metadataFilePath, (err, metadata) ->
+        data.metadataFilePath = metadataFilePath
+        data.metadata = metadata
+        next(err, data)
+
+    tasks.push (data, next) ->
+      data.metadata.apmInstallSource =
+        type: "git"
+        source: packageUrl
+        sha: data.sha
+      CSON.writeFile data.metadataFilePath, data.metadata, (err) ->
+        next(err, data)
+
+    tasks.push (data, next) =>
+      {name} = data.metadata
+      targetDir = path.join(@atomPackagesDirectory, name)
+      fs.cp cloneDir, targetDir, next
+
+    iteratee = (currentData, task, next) -> task(currentData, next)
+    async.reduce tasks, {}, iteratee, callback
 
   installGitPackageDependencies: (directory, options, callback) =>
-    tasks = []
-
     options.cwd = directory
-    tasks.push (cb) => @installDependencies(options, cb)
-    tasks.push (cb) -> CSON.readFile(CSON.resolve(path.join(directory, 'package')), cb)
-
-    async.waterfall tasks, (err, metadata) ->
-      callback(err, metadata)
+    @installDependencies(options, callback)
 
   cloneGitPackage: (packageInfo, cloneDir, callback) ->
     Develop = require './develop'

        else
          callback()

  run: (options) ->
    {callback} = options
    options = @parseOptions(options.commandArgs)

      gitPackageInfo = @getHostedGitInfo(name)

      if gitPackageInfo
        @installGitPackage name, gitPackageInfo, options, callback
      else if name is '.'
        @installDependencies(options, callback)
      else # is registered package
