@@ -5,7 +5,7 @@ use self::types::{ParsedVersion, VersionType};
5
5
use super :: directories;
6
6
use crate :: {
7
7
config:: Config ,
8
- github_requests:: { deserialize_response, UpstreamVersion } ,
8
+ github_requests:: { deserialize_response, RepoCommit , UpstreamVersion } ,
9
9
} ;
10
10
use anyhow:: { anyhow, Context , Result } ;
11
11
use regex:: Regex ;
@@ -37,6 +37,16 @@ pub async fn parse_version_type(client: &Client, version: &str) -> Result<Parsed
37
37
semver : Some ( Version :: parse ( & cloned_version. replace ( 'v' , "" ) ) ?) ,
38
38
} )
39
39
}
40
+ "head" | "git" | "HEAD" => {
41
+ info ! ( "Fetching latest commit" ) ;
42
+ let latest_commit = get_latest_commit ( client) . await ?;
43
+ Ok ( ParsedVersion {
44
+ tag_name : latest_commit. chars ( ) . take ( 7 ) . collect ( ) ,
45
+ version_type : VersionType :: Hash ,
46
+ non_parsed_string : latest_commit,
47
+ semver : None ,
48
+ } )
49
+ }
40
50
_ => {
41
51
let version_regex = Regex :: new ( r"^v?[0-9]+\.[0-9]+\.[0-9]+$" ) ?;
42
52
let hash_regex = Regex :: new ( r"\b[0-9a-f]{5,40}\b" ) ?;
@@ -143,3 +153,18 @@ async fn search_stable_version(client: &Client) -> Result<String> {
143
153
. ok_or ( anyhow ! ( "Cannot find version of stable release" ) ) ?;
144
154
Ok ( stable_pin_release. tag_name . clone ( ) )
145
155
}
156
+
157
+ async fn get_latest_commit ( client : & Client ) -> Result < String > {
158
+ let response = client
159
+ . get ( "https://api.github.com/repos/neovim/neovim/commits/master" )
160
+ . header ( "user-agent" , "bob" )
161
+ . header ( "Accept" , "application/vnd.github.v3+json" )
162
+ . send ( )
163
+ . await ?
164
+ . text ( )
165
+ . await ?;
166
+
167
+ let commit: RepoCommit = deserialize_response ( response) ?;
168
+
169
+ Ok ( commit. sha )
170
+ }
0 commit comments