mirror of
https://github.com/qwjyh/xdbm
synced 2025-04-20 19:55:49 +09:00
Compare commits
4 commits
ed781612ec
...
dfb6694248
Author | SHA1 | Date | |
---|---|---|---|
|
dfb6694248 | ||
c1ba761ddb | |||
f31ea1bbce | |||
8c1abbd563 |
2 changed files with 3 additions and 52 deletions
18
src/main.rs
18
src/main.rs
|
@ -156,23 +156,7 @@ fn add_and_commit(repo: &Repository, path: &Path, message: &str) -> Result<Oid,
|
|||
index.write()?;
|
||||
let oid = index.write_tree()?;
|
||||
let tree = repo.find_tree(oid)?;
|
||||
let config = {
|
||||
let mut config = git2::Config::open_default()?;
|
||||
if log::log_enabled!(log::Level::Trace) {
|
||||
trace!("before reading local config");
|
||||
config
|
||||
.entries(None)?
|
||||
.for_each(|entry| trace!("{:?} = {:?}", entry.name(), entry.value()))?;
|
||||
}
|
||||
config.add_file(&path.join(".git/config"), git2::ConfigLevel::Local, false)?;
|
||||
if log::log_enabled!(log::Level::Trace) {
|
||||
trace!("after reading local config");
|
||||
config
|
||||
.entries(None)?
|
||||
.for_each(|entry| trace!("{:?} = {:?}", entry.name(), entry.value()))?;
|
||||
}
|
||||
config
|
||||
};
|
||||
let config = repo.config()?;
|
||||
let signature = git2::Signature::now(
|
||||
config.get_entry("user.name")?.value().unwrap(),
|
||||
config.get_entry("user.email")?.value().unwrap(),
|
||||
|
|
37
tests/cli.rs
37
tests/cli.rs
|
@ -2,10 +2,9 @@ mod integrated_test {
|
|||
use std::{
|
||||
fs::{self, DirBuilder, File},
|
||||
io::{self, BufWriter, Write},
|
||||
ops::Not,
|
||||
};
|
||||
|
||||
use anyhow::{Context, Ok, Result};
|
||||
use anyhow::{Ok, Result};
|
||||
use assert_cmd::{assert::OutputAssertExt, Command};
|
||||
use git2::Repository;
|
||||
use log::trace;
|
||||
|
@ -41,39 +40,6 @@ mod integrated_test {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn git_init() -> Result<()> {
|
||||
let temp_dir = assert_fs::TempDir::new()?;
|
||||
setup_gitconfig(temp_dir.path())?;
|
||||
let repo = git2::Repository::init(temp_dir.path())?;
|
||||
eprintln!("{:?}", repo.path());
|
||||
let git_status = std::process::Command::new("git")
|
||||
.args(["status"])
|
||||
.current_dir(temp_dir.path())
|
||||
.spawn()
|
||||
.context("git status")?
|
||||
.wait()
|
||||
.context("didn't complete")?;
|
||||
eprintln!("{}", git_status);
|
||||
let git_config = std::process::Command::new("git")
|
||||
.args(["config", "--list"])
|
||||
.current_dir(temp_dir.path())
|
||||
.spawn()
|
||||
.context("git status")?
|
||||
.wait()
|
||||
.context("didn't complete")?;
|
||||
eprintln!("{}", git_config);
|
||||
let git_config = std::process::Command::new("git")
|
||||
.args(["config", "--list", "--local"])
|
||||
.current_dir(temp_dir.path())
|
||||
.spawn()
|
||||
.context("git status")?
|
||||
.wait()
|
||||
.context("didn't complete")?;
|
||||
eprintln!("{}", git_config);
|
||||
Err(anyhow::anyhow!("finished (error for debug)"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_device() -> Result<()> {
|
||||
let config_dir = assert_fs::TempDir::new()?;
|
||||
|
@ -291,6 +257,7 @@ mod integrated_test {
|
|||
//
|
||||
// devices: first, second
|
||||
let config_dir_2 = assert_fs::TempDir::new()?;
|
||||
setup_gitconfig(&config_dir_2)?;
|
||||
let mut cmd2 = Command::cargo_bin("xdbm")?;
|
||||
cmd2.arg("-c")
|
||||
.arg(config_dir_2.path())
|
||||
|
|
Loading…
Add table
Reference in a new issue