@@ -3,7 +3,7 @@ use cargo::{
3
3
util:: interning:: InternedString ,
4
4
sources:: PathSource ,
5
5
} ;
6
- use log:: warn;
6
+ use log:: { warn, trace } ;
7
7
use std:: {
8
8
collections:: { HashSet , HashMap } ,
9
9
error:: Error , fs,
@@ -60,23 +60,29 @@ where
60
60
( graph, map)
61
61
}
62
62
63
- pub fn changed_packages < ' a > ( ws : & ' a Workspace , reference : & str ) -> HashSet < Package > {
63
+ pub fn changed_packages < ' a > ( ws : & ' a Workspace , reference : & str ) -> Result < HashSet < Package > , String > {
64
+
65
+ ws. config ( )
66
+ . shell ( )
67
+ . status ( "Calculating" , format ! ( "git diff since {:}" , reference) )
68
+ . expect ( "Writing to Shell doesn't fail" ) ;
69
+
64
70
let path = ws. root ( ) ;
65
- println ! ( "{:?}" , path) ;
66
- let repo = Repository :: open ( & path ) . expect ( "Workspace isn't a git repo" ) ;
71
+ let repo = Repository :: open ( & path)
72
+ . map_err ( |e| format ! ( "Workspace isn't a git repo: {:?}" , e ) ) ? ;
67
73
let current_head = repo. head ( )
68
74
. and_then ( |b| b. peel_to_commit ( ) )
69
75
. and_then ( |c| c. tree ( ) )
70
- . expect ( "Could not determine current git HEAD" ) ;
76
+ . map_err ( |e| format ! ( "Could not determine current git HEAD: {:?}" , e ) ) ? ;
71
77
let main = repo
72
- . find_reference ( reference)
78
+ . resolve_reference_from_short_name ( reference)
73
79
. and_then ( |d| d. peel_to_commit ( ) )
74
80
. and_then ( |c| c. tree ( ) )
75
- . expect ( "Reference not found in git repository" ) ;
81
+ . map_err ( |e| format ! ( "Reference not found in git repository: {:?}" , e ) ) ? ;
76
82
77
83
let diff = repo
78
84
. diff_tree_to_tree ( Some ( & current_head) , Some ( & main) , None )
79
- . expect ( "Diffing failed" ) ;
85
+ . map_err ( |e| format ! ( "Diffing failed: {:?}" , e ) ) ? ;
80
86
81
87
let files = diff
82
88
. deltas ( )
@@ -85,6 +91,8 @@ pub fn changed_packages<'a>(ws: &'a Workspace, reference: &str) -> HashSet<Packa
85
91
. map ( |l| path. join ( l) )
86
92
. collect :: < Vec < _ > > ( ) ;
87
93
94
+ trace ! ( "Files changed since: {:#?}" , files) ;
95
+
88
96
let mut packages = HashSet :: new ( ) ;
89
97
90
98
for m in members_deep ( ws) {
@@ -97,7 +105,7 @@ pub fn changed_packages<'a>(ws: &'a Workspace, reference: &str) -> HashSet<Packa
97
105
}
98
106
}
99
107
100
- packages
108
+ Ok ( packages)
101
109
}
102
110
103
111
// Find all members of the workspace, into the total depth
0 commit comments