@@ -65,12 +65,11 @@ pub(crate) fn install(
65
65
66
66
for dep in dependencies {
67
67
let DependencyInstallOpts { no_git, no_commit, quiet } = opts;
68
- let path = libs. join ( & dep. name ) ;
69
- p_println ! ( !quiet => "Installing {} in {:?}, (url: {}, tag: {:?})" , dep. name, path, dep. url, dep. tag) ;
68
+ p_println ! ( !quiet => "Installing {} in {:?}, (url: {}, tag: {:?})" , dep. name, & libs. join( & dep. name) , dep. url, dep. tag) ;
70
69
if no_git {
71
- install_as_folder ( & dep, & path ) ?;
70
+ install_as_folder ( & dep, & libs ) ?;
72
71
} else {
73
- install_as_submodule ( & dep, root , & path , no_commit) ?;
72
+ install_as_submodule ( & dep, & libs , no_commit) ?;
74
73
}
75
74
76
75
p_println ! ( !quiet => " {} {}" , Colour :: Green . paint( "Installed" ) , dep. name) ;
@@ -79,48 +78,44 @@ pub(crate) fn install(
79
78
}
80
79
81
80
/// installs the dependency as an ordinary folder instead of a submodule
82
- fn install_as_folder ( dep : & Dependency , path : & Path ) -> eyre:: Result < ( ) > {
81
+ fn install_as_folder ( dep : & Dependency , libs : & Path ) -> eyre:: Result < ( ) > {
83
82
Command :: new ( "git" )
84
- . args ( & [ "clone" , & dep. url , & path. display ( ) . to_string ( ) ] )
83
+ . args ( & [ "clone" , & dep. url , & dep. name ] )
84
+ . current_dir ( & libs)
85
85
. stdout ( Stdio :: piped ( ) )
86
86
. spawn ( ) ?
87
87
. wait ( ) ?;
88
88
89
89
if let Some ( ref tag) = dep. tag {
90
90
Command :: new ( "git" )
91
91
. args ( & [ "checkout" , tag] )
92
- . current_dir ( & path )
92
+ . current_dir ( & libs . join ( & dep . name ) )
93
93
. stdout ( Stdio :: piped ( ) )
94
94
. stderr ( Stdio :: piped ( ) )
95
95
. spawn ( ) ?
96
96
. wait ( ) ?;
97
97
}
98
98
99
99
// rm git artifacts
100
- std:: fs:: remove_dir_all ( path . join ( ".git" ) ) ?;
100
+ std:: fs:: remove_dir_all ( libs . join ( & dep . name ) . join ( ".git" ) ) ?;
101
101
102
102
Ok ( ( ) )
103
103
}
104
104
105
105
/// installs the dependency as new submodule
106
- fn install_as_submodule (
107
- dep : & Dependency ,
108
- root : & Path ,
109
- path : & Path ,
110
- no_commit : bool ,
111
- ) -> eyre:: Result < ( ) > {
106
+ fn install_as_submodule ( dep : & Dependency , libs : & Path , no_commit : bool ) -> eyre:: Result < ( ) > {
112
107
// install the dep
113
108
Command :: new ( "git" )
114
- . args ( & [ "submodule" , "add" , & dep. url , & path . display ( ) . to_string ( ) ] )
115
- . current_dir ( & root )
109
+ . args ( & [ "submodule" , "add" , & dep. url , & dep . name ] )
110
+ . current_dir ( & libs )
116
111
. stdout ( Stdio :: piped ( ) )
117
112
. stderr ( Stdio :: piped ( ) )
118
113
. spawn ( ) ?
119
114
. wait ( ) ?;
120
115
// call update on it
121
116
Command :: new ( "git" )
122
- . args ( & [ "submodule" , "update" , "--init" , "--recursive" , & path . display ( ) . to_string ( ) ] )
123
- . current_dir ( & root )
117
+ . args ( & [ "submodule" , "update" , "--init" , "--recursive" , & dep . name ] )
118
+ . current_dir ( & libs )
124
119
. stdout ( Stdio :: piped ( ) )
125
120
. stderr ( Stdio :: piped ( ) )
126
121
. spawn ( ) ?
@@ -130,14 +125,14 @@ fn install_as_submodule(
130
125
let message = if let Some ( ref tag) = dep. tag {
131
126
Command :: new ( "git" )
132
127
. args ( & [ "checkout" , "--recurse-submodules" , tag] )
133
- . current_dir ( & path )
128
+ . current_dir ( & libs . join ( & dep . name ) )
134
129
. stdout ( Stdio :: piped ( ) )
135
130
. stderr ( Stdio :: piped ( ) )
136
131
. spawn ( ) ?
137
132
. wait ( ) ?;
138
133
139
134
if !no_commit {
140
- Command :: new ( "git" ) . args ( & [ "add" , & path . display ( ) . to_string ( ) ] ) . spawn ( ) ?. wait ( ) ?;
135
+ Command :: new ( "git" ) . args ( & [ "add" , & libs . display ( ) . to_string ( ) ] ) . spawn ( ) ?. wait ( ) ?;
141
136
}
142
137
format ! ( "forge install: {}\n \n {}" , dep. name, tag)
143
138
} else {
@@ -147,7 +142,7 @@ fn install_as_submodule(
147
142
if !no_commit {
148
143
Command :: new ( "git" )
149
144
. args ( & [ "commit" , "-m" , & message] )
150
- . current_dir ( & root )
145
+ . current_dir ( & libs )
151
146
. stdout ( Stdio :: piped ( ) )
152
147
. spawn ( ) ?
153
148
. wait ( ) ?;
0 commit comments