Windows: look for git repos in the startup directory
This commit is contained in:
20
Cargo.lock
generated
20
Cargo.lock
generated
@@ -943,6 +943,19 @@ dependencies = [
|
|||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parselnk"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d098204d9ef47f80312460c1555a152972ea9f0a67487a77b2ab7e03fd510d4f"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.2.1",
|
||||||
|
"byteorder",
|
||||||
|
"chrono",
|
||||||
|
"thiserror",
|
||||||
|
"widestring",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.1.0"
|
version = "2.1.0"
|
||||||
@@ -1700,6 +1713,7 @@ dependencies = [
|
|||||||
"nix",
|
"nix",
|
||||||
"notify-rust",
|
"notify-rust",
|
||||||
"openssl-probe",
|
"openssl-probe",
|
||||||
|
"parselnk",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"regex",
|
"regex",
|
||||||
"rust-ini",
|
"rust-ini",
|
||||||
@@ -1958,6 +1972,12 @@ dependencies = [
|
|||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "widestring"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ self_update_crate = { version = "0.23.0", optional = true, package = "self_upda
|
|||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
self_update_crate = { version = "0.23.0", optional = true, package = "self_update", features = ["archive-zip", "compression-zip-deflate"] }
|
self_update_crate = { version = "0.23.0", optional = true, package = "self_update", features = ["archive-zip", "compression-zip-deflate"] }
|
||||||
winapi = "0.3.9"
|
winapi = "0.3.9"
|
||||||
|
parselnk = "0.1"
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
rust-ini = "0.16.0"
|
rust-ini = "0.16.0"
|
||||||
|
|||||||
@@ -222,6 +222,9 @@ fn run() -> Result<()> {
|
|||||||
.join("Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState"),
|
.join("Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState"),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
windows::insert_startup_scripts(&ctx, &mut git_repos).ok();
|
||||||
|
|
||||||
if let Some(profile) = powershell.profile() {
|
if let Some(profile) = powershell.profile() {
|
||||||
git_repos.insert_if_repo(profile);
|
git_repos.insert_if_repo(profile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
use crate::error::SkipStep;
|
|
||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::executor::{CommandExt, RunType};
|
use crate::executor::{CommandExt, RunType};
|
||||||
use crate::powershell;
|
use crate::powershell;
|
||||||
use crate::terminal::print_separator;
|
use crate::terminal::print_separator;
|
||||||
use crate::utils::require;
|
use crate::utils::require;
|
||||||
|
use crate::{error::SkipStep, steps::git::Repositories};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use std::process::Command;
|
use log::debug;
|
||||||
|
use std::convert::TryFrom;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::{ffi::OsStr, process::Command};
|
||||||
|
|
||||||
pub fn run_chocolatey(ctx: &ExecutionContext) -> Result<()> {
|
pub fn run_chocolatey(ctx: &ExecutionContext) -> Result<()> {
|
||||||
let choco = require("choco")?;
|
let choco = require("choco")?;
|
||||||
@@ -85,3 +88,25 @@ pub fn windows_update(ctx: &ExecutionContext) -> Result<()> {
|
|||||||
pub fn reboot() {
|
pub fn reboot() {
|
||||||
Command::new("shutdown").args(&["/R", "/T", "0"]).spawn().ok();
|
Command::new("shutdown").args(&["/R", "/T", "0"]).spawn().ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn insert_startup_scripts(ctx: &ExecutionContext, git_repos: &mut Repositories) -> Result<()> {
|
||||||
|
let startup_dir = ctx
|
||||||
|
.base_dirs()
|
||||||
|
.data_dir()
|
||||||
|
.join("Microsoft\\Windows\\Start Menu\\Programs\\Startup");
|
||||||
|
for entry in std::fs::read_dir(&startup_dir)? {
|
||||||
|
if let Ok(entry) = entry {
|
||||||
|
let path = entry.path();
|
||||||
|
if path.extension().and_then(OsStr::to_str) == Some("lnk") {
|
||||||
|
if let Ok(lnk) = parselnk::Lnk::try_from(Path::new(&path)) {
|
||||||
|
debug!("Startup link: {:?}", lnk);
|
||||||
|
if let Some(path) = lnk.relative_path() {
|
||||||
|
git_repos.insert_if_repo(&startup_dir.join(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user