@@ -4,56 +4,64 @@ use crate::{
4
4
project_root, Mode , Result ,
5
5
} ;
6
6
7
- pub fn run_release ( dry_run : bool ) -> Result < ( ) > {
8
- if !dry_run {
9
- run ! ( "git switch release" ) ?;
10
- run ! ( "git fetch upstream --tags --force" ) ?;
11
- run ! ( "git reset --hard tags/nightly" ) ?;
12
- run ! ( "git push" ) ?;
13
- }
14
- codegen:: generate_assists_docs ( Mode :: Overwrite ) ?;
15
- codegen:: generate_feature_docs ( Mode :: Overwrite ) ?;
7
+ pub struct ReleaseCmd {
8
+ pub dry_run : bool ,
9
+ }
16
10
17
- let website_root = project_root ( ) . join ( "../rust-analyzer.github.io" ) ;
18
- let changelog_dir = website_root. join ( "./thisweek/_posts" ) ;
11
+ impl ReleaseCmd {
12
+ pub fn run ( self ) -> Result < ( ) > {
13
+ if !self . dry_run {
14
+ run ! ( "git switch release" ) ?;
15
+ run ! ( "git fetch upstream --tags --force" ) ?;
16
+ run ! ( "git reset --hard tags/nightly" ) ?;
17
+ run ! ( "git push" ) ?;
18
+ }
19
+ codegen:: generate_assists_docs ( Mode :: Overwrite ) ?;
20
+ codegen:: generate_feature_docs ( Mode :: Overwrite ) ?;
19
21
20
- let today = date_iso ( ) ?;
21
- let commit = run ! ( "git rev-parse HEAD" ) ?;
22
- let changelog_n = fs2:: read_dir ( changelog_dir. as_path ( ) ) ?. count ( ) ;
22
+ let website_root = project_root ( ) . join ( "../rust-analyzer.github.io" ) ;
23
+ let changelog_dir = website_root. join ( "./thisweek/_posts" ) ;
23
24
24
- let contents = format ! (
25
- "\
26
- = Changelog #{}
27
- :sectanchors:
28
- :page-layout: post
25
+ let today = date_iso ( ) ?;
26
+ let commit = run ! ( "git rev-parse HEAD" ) ?;
27
+ let changelog_n = fs2:: read_dir ( changelog_dir. as_path ( ) ) ?. count ( ) ;
29
28
30
- Commit: commit:{}[] +
31
- Release: release:{}[]
29
+ let contents = format ! (
30
+ "\
31
+ = Changelog #{}
32
+ :sectanchors:
33
+ :page-layout: post
32
34
33
- == New Features
35
+ Commit: commit:{}[] +
36
+ Release: release:{}[]
34
37
35
- * pr:[] .
38
+ == New Features
36
39
37
- == Fixes
40
+ * pr:[] .
38
41
39
- == Internal Improvements
40
- " ,
41
- changelog_n, commit, today
42
- ) ;
42
+ == Fixes
43
43
44
- let path = changelog_dir. join ( format ! ( "{}-changelog-{}.adoc" , today, changelog_n) ) ;
45
- fs2:: write ( & path, & contents) ?;
44
+ == Internal Improvements
45
+ " ,
46
+ changelog_n, commit, today
47
+ ) ;
46
48
47
- for & adoc in [ "manual.adoc" , "generated_features.adoc" , "generated_assists.adoc" ] . iter ( ) {
48
- let src = project_root ( ) . join ( "./docs/user/" ) . join ( adoc) ;
49
- let dst = website_root. join ( adoc) ;
50
- fs2:: copy ( src, dst) ?;
51
- }
49
+ let path = changelog_dir. join ( format ! ( "{}-changelog-{}.adoc" , today, changelog_n) ) ;
50
+ fs2:: write ( & path, & contents) ?;
52
51
53
- let tags = run ! ( "git tag --list" ; echo = false ) ?;
54
- let prev_tag = tags. lines ( ) . filter ( |line| is_release_tag ( line) ) . last ( ) . unwrap ( ) ;
52
+ for & adoc in [ "manual.adoc" , "generated_features.adoc" , "generated_assists.adoc" ] . iter ( ) {
53
+ let src = project_root ( ) . join ( "./docs/user/" ) . join ( adoc) ;
54
+ let dst = website_root. join ( adoc) ;
55
+ fs2:: copy ( src, dst) ?;
56
+ }
55
57
56
- println ! ( "\n git log {}..HEAD --merges --reverse" , prev_tag) ;
58
+ let tags = run ! ( "git tag --list" ; echo = false ) ?;
59
+ let prev_tag = tags. lines ( ) . filter ( |line| is_release_tag ( line) ) . last ( ) . unwrap ( ) ;
57
60
58
- Ok ( ( ) )
61
+ let git_log = run ! ( "git log {}..HEAD --merges --reverse" , prev_tag; echo = false ) ?;
62
+ let git_log_dst = website_root. join ( "git.log" ) ;
63
+ fs2:: write ( git_log_dst, & git_log) ?;
64
+
65
+ Ok ( ( ) )
66
+ }
59
67
}
0 commit comments