diff --git a/.github/config-schema.json b/.github/config-schema.json index a01d83c01..22b938e0c 100644 --- a/.github/config-schema.json +++ b/.github/config-schema.json @@ -1397,7 +1397,7 @@ "Rsx" ], "detect_files": [ - ".Rprofile" + "DESCRIPTION" ], "detect_folders": [ ".Rproj.user" @@ -5100,7 +5100,7 @@ }, "detect_files": { "default": [ - ".Rprofile" + "DESCRIPTION" ], "type": "array", "items": { diff --git a/src/configs/rlang.rs b/src/configs/rlang.rs index 3982b723d..c759f570f 100644 --- a/src/configs/rlang.rs +++ b/src/configs/rlang.rs @@ -27,7 +27,7 @@ impl<'a> Default for RLangConfig<'a> { symbol: "📐 ", disabled: false, detect_extensions: vec!["R", "Rd", "Rmd", "Rproj", "Rsx"], - detect_files: vec![".Rprofile"], + detect_files: vec!["DESCRIPTION"], detect_folders: vec![".Rproj.user"], } } diff --git a/src/modules/package.rs b/src/modules/package.rs index 4c9f20b15..f72cb059b 100644 --- a/src/modules/package.rs +++ b/src/modules/package.rs @@ -310,6 +310,13 @@ fn get_dart_pub_version(context: &Context, config: &PackageConfig) -> Option Option { + let file_contents = context.read_file_from_pwd("DESCRIPTION")?; + let re = Regex::new(r"(?m)^Version:\s*(?P.*$)").unwrap(); + let caps = re.captures(&file_contents)?; + format_version(&caps["version"], config.version_format) +} + fn get_version(context: &Context, config: &PackageConfig) -> Option { let package_version_fn: Vec Option> = vec![ get_cargo_version, @@ -330,6 +337,7 @@ fn get_version(context: &Context, config: &PackageConfig) -> Option { get_sbt_version, get_daml_project_version, get_dart_pub_version, + get_rlang_version, ]; package_version_fn.iter().find_map(|f| f(context, config)) @@ -1402,6 +1410,19 @@ environment: project_dir.close() } + #[test] + fn test_extract_rlang_version() -> io::Result<()> { + let config_name = "DESCRIPTION"; + let config_content = " +Package: starship +Version: 1.0.0 +Title: Starship +"; + let project_dir = create_project_dir()?; + fill_config(&project_dir, config_name, Some(config_content))?; + expect_output(&project_dir, Some("v1.0.0"), None); + project_dir.close() + } fn create_project_dir() -> io::Result { tempfile::tempdir() } diff --git a/src/modules/rlang.rs b/src/modules/rlang.rs index a3902497f..5620e025e 100644 --- a/src/modules/rlang.rs +++ b/src/modules/rlang.rs @@ -133,9 +133,9 @@ https://www.gnu.org/licenses/."#; } #[test] - fn folder_with_rprofile_files() -> io::Result<()> { + fn folder_with_description_files() -> io::Result<()> { let dir = tempfile::tempdir()?; - File::create(dir.path().join(".Rprofile"))?.sync_all()?; + File::create(dir.path().join("DESCRIPTION"))?.sync_all()?; check_r_render(&dir); dir.close() }