@@ -30,77 +30,6 @@ pub fn output_result(cmd: &mut Command) -> Result<String, String> {
30
30
String :: from_utf8 ( output. stdout ) . map_err ( |err| format ! ( "{err:?}" ) )
31
31
}
32
32
33
- /// Finds the remote for rust-lang/rust.
34
- /// For example for these remotes it will return `upstream`.
35
- /// ```text
36
- /// origin https://github.com/pietroalbani/rust.git (fetch)
37
- /// origin https://github.com/pietroalbani/rust.git (push)
38
- /// upstream https://github.com/rust-lang/rust (fetch)
39
- /// upstream https://github.com/rust-lang/rust (push)
40
- /// ```
41
- pub fn get_rust_lang_rust_remote (
42
- config : & GitConfig < ' _ > ,
43
- git_dir : Option < & Path > ,
44
- ) -> Result < String , String > {
45
- let mut git = Command :: new ( "git" ) ;
46
- if let Some ( git_dir) = git_dir {
47
- git. current_dir ( git_dir) ;
48
- }
49
- git. args ( [ "config" , "--local" , "--get-regex" , "remote\\ ..*\\ .url" ] ) ;
50
- let stdout = output_result ( & mut git) ?;
51
-
52
- let rust_lang_remote = stdout
53
- . lines ( )
54
- . find ( |remote| remote. contains ( config. git_repository ) )
55
- . ok_or_else ( || format ! ( "{} remote not found" , config. git_repository) ) ?;
56
-
57
- let remote_name =
58
- rust_lang_remote. split ( '.' ) . nth ( 1 ) . ok_or_else ( || "remote name not found" . to_owned ( ) ) ?;
59
- Ok ( remote_name. into ( ) )
60
- }
61
-
62
- pub fn rev_exists ( rev : & str , git_dir : Option < & Path > ) -> Result < bool , String > {
63
- let mut git = Command :: new ( "git" ) ;
64
- if let Some ( git_dir) = git_dir {
65
- git. current_dir ( git_dir) ;
66
- }
67
- git. args ( [ "rev-parse" , rev] ) ;
68
- let output = git. output ( ) . map_err ( |err| format ! ( "{err:?}" ) ) ?;
69
-
70
- match output. status . code ( ) {
71
- Some ( 0 ) => Ok ( true ) ,
72
- Some ( 128 ) => Ok ( false ) ,
73
- None => Err ( format ! (
74
- "git didn't exit properly: {}" ,
75
- String :: from_utf8( output. stderr) . map_err( |err| format!( "{err:?}" ) ) ?
76
- ) ) ,
77
- Some ( code) => Err ( format ! (
78
- "git command exited with status code: {code}: {}" ,
79
- String :: from_utf8( output. stderr) . map_err( |err| format!( "{err:?}" ) ) ?
80
- ) ) ,
81
- }
82
- }
83
-
84
- /// Returns the master branch from which we can take diffs to see changes.
85
- /// This will usually be rust-lang/rust master, but sometimes this might not exist.
86
- /// This could be because the user is updating their forked master branch using the GitHub UI
87
- /// and therefore doesn't need an upstream master branch checked out.
88
- /// We will then fall back to origin/master in the hope that at least this exists.
89
- pub fn updated_master_branch (
90
- config : & GitConfig < ' _ > ,
91
- git_dir : Option < & Path > ,
92
- ) -> Result < String , String > {
93
- let upstream_remote = get_rust_lang_rust_remote ( config, git_dir) ?;
94
- let branch = config. nightly_branch ;
95
- for upstream_master in [ format ! ( "{upstream_remote}/{branch}" ) , format ! ( "origin/{branch}" ) ] {
96
- if rev_exists ( & upstream_master, git_dir) ? {
97
- return Ok ( upstream_master) ;
98
- }
99
- }
100
-
101
- Err ( "Cannot find any suitable upstream master branch" . to_owned ( ) )
102
- }
103
-
104
33
/// Represents the result of checking whether a set of paths
105
34
/// have been modified locally or not.
106
35
#[ derive( PartialEq , Debug ) ]
@@ -312,13 +241,7 @@ pub fn get_git_modified_files(
312
241
}
313
242
314
243
/// Returns the files that haven't been added to git yet.
315
- pub fn get_git_untracked_files (
316
- config : & GitConfig < ' _ > ,
317
- git_dir : Option < & Path > ,
318
- ) -> Result < Option < Vec < String > > , String > {
319
- let Ok ( _updated_master) = updated_master_branch ( config, git_dir) else {
320
- return Ok ( None ) ;
321
- } ;
244
+ pub fn get_git_untracked_files ( git_dir : Option < & Path > ) -> Result < Option < Vec < String > > , String > {
322
245
let mut git = Command :: new ( "git" ) ;
323
246
if let Some ( git_dir) = git_dir {
324
247
git. current_dir ( git_dir) ;
0 commit comments