about summary refs log tree commit diff
path: root/src/librustpkg/package_source.rs
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2013-07-09 18:28:00 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2013-07-15 12:59:48 -0700
commit0fa9ad86739e84805cabc2131d6607b4160bc556 (patch)
tree0b0b89343702eb0798dec1e5c14ee1cce6e4f409 /src/librustpkg/package_source.rs
parent9c22f6587049a13c74e1c07e0f6590ba356a3be9 (diff)
downloadrust-0fa9ad86739e84805cabc2131d6607b4160bc556.tar.gz
rust-0fa9ad86739e84805cabc2131d6607b4160bc556.zip
rustpkg: Handle local git repositories
rustpkg can now build code from a local git repository. In the
case where the local repo is in a directory not in the RUST_PATH,
it checks out the repository into a directory in the first workspace
in the RUST_PATH.

The tests no longer try to connect to github.com, which should
solve some of the sporadic failures we've been seeing.
Diffstat (limited to 'src/librustpkg/package_source.rs')
-rw-r--r--src/librustpkg/package_source.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs
index 54ad888e2ae..668157bebb9 100644
--- a/src/librustpkg/package_source.rs
+++ b/src/librustpkg/package_source.rs
@@ -15,6 +15,7 @@ use std::{os, run, str};
 use context::*;
 use crate::Crate;
 use messages::*;
+use source_control::git_clone;
 use path_util::pkgid_src_in_workspace;
 use util::compile_crate;
 use version::{ExactRevision, SemanticVersion, NoVersion};
@@ -76,9 +77,10 @@ impl PkgSrc {
         dir
     }
 
-    /// Try interpreting self's package id as a remote package, and try
+    /// Try interpreting self's package id as a git repository, and try
     /// fetching it and caching it in a local directory. Return the cached directory
-    /// if this was successful, None otherwise
+    /// if this was successful, None otherwise. Similarly, if the package id
+    /// refers to a git repo on the local version, also check it out.
     /// (right now we only support git)
     pub fn fetch_git(&self) -> Option<Path> {
 
@@ -87,6 +89,18 @@ impl PkgSrc {
         // Git can't clone into a non-empty directory
         os::remove_dir_recursive(&local);
 
+        debug!("Checking whether %s exists locally. Cwd = %s, does it? %?",
+               self.id.local_path.to_str(),
+               os::getcwd().to_str(),
+               os::path_exists(&*self.id.local_path));
+
+        if os::path_exists(&*self.id.local_path) {
+            debug!("%s exists locally! Cloning it into %s",
+                   self.id.local_path.to_str(), local.to_str());
+            git_clone(&*self.id.local_path, &local, &self.id.version);
+            return Some(local);
+        }
+
         let url = fmt!("https://%s", self.id.remote_path.to_str());
         let branch_args = match self.id.version {
                       NoVersion => ~[],