@@ -9,7 +9,7 @@ use xshell::{cmd, Shell};
9
9
/// Used for rustc syncs.
10
10
const JOSH_FILTER : & str = ":/src/doc/rustc-dev-guide" ;
11
11
const JOSH_PORT : u16 = 42042 ;
12
- const UPSTREAM_REPO : & str = "rust-lang /rust" ;
12
+ const UPSTREAM_REPO : & str = "kobzol /rust" ;
13
13
14
14
pub struct GitSync {
15
15
dir : PathBuf ,
@@ -45,6 +45,11 @@ impl GitSync {
45
45
let josh_url =
46
46
format ! ( "http://localhost:{JOSH_PORT}/{UPSTREAM_REPO}.git@{commit}{JOSH_FILTER}.git" ) ;
47
47
48
+ let previous_base_commit = sh. read_file ( "rust-version" ) ?. trim ( ) . to_string ( ) ;
49
+ if previous_base_commit == commit {
50
+ return Err ( anyhow:: anyhow!( "No changes since last pull" ) ) ;
51
+ }
52
+
48
53
// Update rust-version file. As a separate commit, since making it part of
49
54
// the merge has confused the heck out of josh in the past.
50
55
// We pass `--no-verify` to avoid running git hooks.
@@ -76,12 +81,22 @@ impl GitSync {
76
81
} ;
77
82
let num_roots_before = num_roots ( ) ?;
78
83
84
+ let sha = cmd ! ( sh, "git rev-parse HEAD" ) . output ( ) . context ( "FAILED to get current commit" ) ?. stdout ;
85
+
79
86
// Merge the fetched commit.
80
87
const MERGE_COMMIT_MESSAGE : & str = "Merge from rustc" ;
81
88
cmd ! ( sh, "git merge FETCH_HEAD --no-verify --no-ff -m {MERGE_COMMIT_MESSAGE}" )
82
89
. run ( )
83
90
. context ( "FAILED to merge new commits, something went wrong" ) ?;
84
91
92
+ let current_sha = cmd ! ( sh, "git rev-parse HEAD" ) . output ( ) . context ( "FAILED to get current commit" ) ?. stdout ;
93
+ if current_sha == sha {
94
+ cmd ! ( sh, "git reset --hard HEAD^" )
95
+ . run ( )
96
+ . expect ( "FAILED to clean up after creating the preparation commit" ) ;
97
+ return Err ( anyhow:: anyhow!( "No merge was performed, nothing to pull. Rolled back the preparation commit." ) ) ;
98
+ }
99
+
85
100
// Check that the number of roots did not increase.
86
101
if num_roots ( ) ? != num_roots_before {
87
102
bail ! ( "Josh created a new root commit. This is probably not the history you want." ) ;
@@ -179,6 +194,7 @@ impl GitSync {
179
194
directories:: ProjectDirs :: from ( "org" , "rust-lang" , "rustc-dev-guide-josh" ) . unwrap ( ) ;
180
195
user_dirs. cache_dir ( ) . to_owned ( )
181
196
} ;
197
+ eprintln ! ( "Using cache dir at {}" , local_dir. display( ) ) ;
182
198
183
199
// Start josh, silencing its output.
184
200
let mut cmd = process:: Command :: new ( "josh-proxy" ) ;
0 commit comments