@@ -17,14 +17,16 @@ mod logwalker;
17
17
pub mod remotes;
18
18
mod reset;
19
19
mod stash;
20
+ mod state;
20
21
pub mod status;
21
22
mod tags;
22
23
pub mod utils;
23
24
24
25
pub use branch:: {
25
26
branch_compare_upstream, checkout_branch, create_branch,
26
- delete_branch, get_branches_info, rename_branch, BranchCompare ,
27
- BranchInfo ,
27
+ delete_branch, get_branches_info,
28
+ merge:: branch_merge_upstream_fastforward, rename:: rename_branch,
29
+ BranchCompare , BranchInfo ,
28
30
} ;
29
31
pub use commit:: { amend, commit, tag} ;
30
32
pub use commit_details:: {
@@ -42,6 +44,7 @@ pub use logwalker::LogWalker;
42
44
pub use remotes:: { fetch_origin, get_default_remote, get_remotes} ;
43
45
pub use reset:: { reset_stage, reset_workdir} ;
44
46
pub use stash:: { get_stashes, stash_apply, stash_drop, stash_save} ;
47
+ pub use state:: { repo_state, RepoState } ;
45
48
pub use tags:: { get_tags, CommitTags , Tags } ;
46
49
pub use utils:: {
47
50
get_head, get_head_tuple, is_bare_repo, is_repo, stage_add_all,
@@ -50,7 +53,10 @@ pub use utils::{
50
53
51
54
#[ cfg( test) ]
52
55
mod tests {
53
- use super :: status:: { get_status, StatusType } ;
56
+ use super :: {
57
+ status:: { get_status, StatusType } ,
58
+ CommitId , LogWalker ,
59
+ } ;
54
60
use crate :: error:: Result ;
55
61
use git2:: Repository ;
56
62
use std:: process:: Command ;
@@ -120,6 +126,23 @@ mod tests {
120
126
Ok ( ( td, repo) )
121
127
}
122
128
129
+ ///
130
+ pub fn repo_clone ( p : & str ) -> Result < ( TempDir , Repository ) > {
131
+ sandbox_config_files ( ) ;
132
+
133
+ let td = TempDir :: new ( ) ?;
134
+
135
+ let td_path = td. path ( ) . as_os_str ( ) . to_str ( ) . unwrap ( ) ;
136
+
137
+ let repo = Repository :: clone ( p, td_path) . unwrap ( ) ;
138
+
139
+ let mut config = repo. config ( ) ?;
140
+ config. set_str ( "user.name" , "name" ) ?;
141
+ config. set_str ( "user.email" , "email" ) ?;
142
+
143
+ Ok ( ( td, repo) )
144
+ }
145
+
123
146
/// Same as repo_init, but the repo is a bare repo (--bare)
124
147
pub fn repo_init_bare ( ) -> Result < ( TempDir , Repository ) > {
125
148
let tmp_repo_dir = TempDir :: new ( ) ?;
@@ -145,6 +168,17 @@ mod tests {
145
168
eprintln ! ( "\n ----\n {}" , cmd) ;
146
169
}
147
170
171
+ /// helper to fetch commmit details using log walker
172
+ pub fn get_commit_ids (
173
+ r : & Repository ,
174
+ max_count : usize ,
175
+ ) -> Vec < CommitId > {
176
+ let mut commit_ids = Vec :: < CommitId > :: new ( ) ;
177
+ LogWalker :: new ( r) . read ( & mut commit_ids, max_count) . unwrap ( ) ;
178
+
179
+ commit_ids
180
+ }
181
+
148
182
fn debug_cmd ( path : & str , cmd : & str ) -> String {
149
183
let output = if cfg ! ( target_os = "windows" ) {
150
184
Command :: new ( "cmd" )
0 commit comments