@@ -82,6 +82,21 @@ public static function &create($repo_path, $source = null) {
8282 public static function open ($ repo_path ) {
8383 return new GitRepo ($ repo_path );
8484 }
85+
86+ /**
87+ * Clones a remote repo into a directory and then returns a GitRepo object
88+ * for the newly created local repo
89+ *
90+ * Accepts a creation path and a remote to clone from
91+ *
92+ * @access public
93+ * @param string repository path
94+ * @param string remote source
95+ * @return GitRepo
96+ **/
97+ public static function &clone_remote ($ repo_path , $ remote ) {
98+ return GitRepo::create_new ($ repo_path , $ remote , true );
99+ }
85100
86101 /**
87102 * Checks if a variable is an instance of GitRepo
@@ -124,13 +139,17 @@ class GitRepo {
124139 * @param string directory to source
125140 * @return GitRepo
126141 */
127- public static function &create_new ($ repo_path , $ source = null ) {
142+ public static function &create_new ($ repo_path , $ source = null , $ remote_source = false ) {
128143 if (is_dir ($ repo_path ) && file_exists ($ repo_path ."/.git " ) && is_dir ($ repo_path ."/.git " )) {
129144 throw new Exception ('" ' .$ repo_path .'" is already a git repository ' );
130145 } else {
131146 $ repo = new self ($ repo_path , true , false );
132147 if (is_string ($ source )) {
133- $ repo ->clone_from ($ source );
148+ if ($ remote_source ) {
149+ $ repo ->clone_remote ($ source );
150+ } else {
151+ $ repo ->clone_from ($ source );
152+ }
134153 } else {
135154 $ repo ->run ('init ' );
136155 }
0 commit comments