File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1252,10 +1252,30 @@ fn download_from_git(target: &Path, url: &str) -> anyhow::Result<()> {
1252
1252
. status ( )
1253
1253
. expect ( "Git clone failed" ) ;
1254
1254
generate_lockfile ( tmpdir. path ( ) ) ;
1255
+
1256
+ // Save downloaded commit SHA to keep information about downloaded revision
1257
+ let git_sha = get_git_sha ( tmpdir. path ( ) ) ?;
1258
+ std:: fs:: write ( tmpdir. path ( ) . join ( "git-commit.txt" ) , git_sha) ?;
1259
+
1260
+ // Remove .git directory to avoid messing with nested git repositories
1261
+ if let Err ( error) = std:: fs:: remove_dir_all ( tmpdir. path ( ) . join ( ".git" ) ) {
1262
+ log:: error!( "Could not delete .git directory: {error:?}" ) ;
1263
+ }
1264
+
1255
1265
execute:: rename ( & tmpdir, & target) ?;
1256
1266
Ok ( ( ) )
1257
1267
}
1258
1268
1269
+ fn get_git_sha ( directory : & Path ) -> anyhow:: Result < String > {
1270
+ let stdout = Command :: new ( "git" )
1271
+ . arg ( "rev-parse" )
1272
+ . arg ( "HEAD" )
1273
+ . current_dir ( directory)
1274
+ . output ( ) ?
1275
+ . stdout ;
1276
+ Ok ( String :: from_utf8 ( stdout) ?)
1277
+ }
1278
+
1259
1279
fn download_from_crates_io ( target_dir : & Path , krate : & str , version : & str ) -> anyhow:: Result < ( ) > {
1260
1280
let url = format ! ( "https://crates.io/api/v1/crates/{krate}/{version}/download" ) ;
1261
1281
let response = reqwest:: blocking:: get ( url)
You can’t perform that action at this time.
0 commit comments