mirror of
https://github.com/gitui-org/gitui
synced 2026-05-23 17:08:21 +00:00
change temporary commit msg file path
we now use `.git/COMMIT_EDITMSG` for vim to recognise
This commit is contained in:
parent
fdcd393ce7
commit
7177bb223b
3 changed files with 18 additions and 13 deletions
|
|
@ -67,8 +67,8 @@ pub use state::{repo_state, RepoState};
|
|||
pub use tags::{get_tags, CommitTags, Tags};
|
||||
pub use tree::{tree_file_content, tree_files, TreeFile};
|
||||
pub use utils::{
|
||||
get_head, get_head_tuple, is_bare_repo, is_repo, stage_add_all,
|
||||
stage_add_file, stage_addremoved, Head,
|
||||
get_head, get_head_tuple, is_bare_repo, is_repo, repo_dir,
|
||||
stage_add_all, stage_add_file, stage_addremoved, Head,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,11 @@ use super::CommitId;
|
|||
use crate::error::{Error, Result};
|
||||
use git2::{IndexAddOption, Repository, RepositoryOpenFlags};
|
||||
use scopetime::scope_time;
|
||||
use std::{fs::File, io::Write, path::Path};
|
||||
use std::{
|
||||
fs::File,
|
||||
io::Write,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
///
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
|
|
@ -56,6 +60,12 @@ pub(crate) fn work_dir(repo: &Repository) -> Result<&Path> {
|
|||
repo.workdir().ok_or(Error::NoWorkDir)
|
||||
}
|
||||
|
||||
/// path to .git folder
|
||||
pub fn repo_dir(repo_path: &str) -> Result<PathBuf> {
|
||||
let repo = repo(repo_path)?;
|
||||
Ok(repo.path().to_owned())
|
||||
}
|
||||
|
||||
///
|
||||
pub fn repo_work_dir(repo_path: &str) -> Result<String> {
|
||||
let repo = repo(repo_path)?;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ use super::{
|
|||
EventState, ExternalEditorComponent,
|
||||
};
|
||||
use crate::{
|
||||
args::get_app_config_path,
|
||||
keys::SharedKeyConfig,
|
||||
queue::{InternalEvent, NeedsUpdate, Queue},
|
||||
strings,
|
||||
|
|
@ -24,7 +23,6 @@ use easy_cast::Cast;
|
|||
use std::{
|
||||
fs::{read_to_string, File},
|
||||
io::{Read, Write},
|
||||
path::PathBuf,
|
||||
};
|
||||
use tui::{
|
||||
backend::Backend,
|
||||
|
|
@ -252,13 +250,10 @@ impl CommitComponent {
|
|||
}
|
||||
|
||||
pub fn show_editor(&mut self) -> Result<()> {
|
||||
const COMMIT_MSG_FILE_NAME: &str = "COMMITMSG_EDITOR";
|
||||
//TODO: use a tmpfile here
|
||||
let mut config_path: PathBuf = get_app_config_path()?;
|
||||
config_path.push(COMMIT_MSG_FILE_NAME);
|
||||
let file_path = sync::repo_dir(CWD)?.join("COMMIT_EDITMSG");
|
||||
|
||||
{
|
||||
let mut file = File::create(&config_path)?;
|
||||
let mut file = File::create(&file_path)?;
|
||||
file.write_fmt(format_args!(
|
||||
"{}\n",
|
||||
self.input.get_text()
|
||||
|
|
@ -269,14 +264,14 @@ impl CommitComponent {
|
|||
)?;
|
||||
}
|
||||
|
||||
ExternalEditorComponent::open_file_in_editor(&config_path)?;
|
||||
ExternalEditorComponent::open_file_in_editor(&file_path)?;
|
||||
|
||||
let mut message = String::new();
|
||||
|
||||
let mut file = File::open(&config_path)?;
|
||||
let mut file = File::open(&file_path)?;
|
||||
file.read_to_string(&mut message)?;
|
||||
drop(file);
|
||||
std::fs::remove_file(&config_path)?;
|
||||
std::fs::remove_file(&file_path)?;
|
||||
|
||||
let message: String = message
|
||||
.lines()
|
||||
|
|
|
|||
Loading…
Reference in a new issue