Added scripts for installing command
This commit is contained in:
parent
b939593445
commit
09cd5a7e31
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1 @@
|
|||||||
something/
|
|
||||||
target/
|
target/
|
||||||
|
@ -50,13 +50,8 @@ Easily add patterns using `git ignore <pattern>` this will by default also help
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum GitActions {
|
enum GitActions {
|
||||||
AddPattern {
|
AddPattern { gitignore_path: PathBuf },
|
||||||
git_path: PathBuf,
|
CreateIgnoreAndAddPattern { git_path: PathBuf },
|
||||||
gitignore_path: PathBuf,
|
|
||||||
},
|
|
||||||
CreateIgnoreAndAddPattern {
|
|
||||||
git_path: PathBuf,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_gitignore_pattern(term: console::Term, pattern: &String) -> eyre::Result<()> {
|
fn add_gitignore_pattern(term: console::Term, pattern: &String) -> eyre::Result<()> {
|
||||||
@ -67,8 +62,7 @@ fn add_gitignore_pattern(term: console::Term, pattern: &String) -> eyre::Result<
|
|||||||
let actions = match search_for_dotgitignore(&curdir)? {
|
let actions = match search_for_dotgitignore(&curdir)? {
|
||||||
// If we have an ignore path, make sure it is in a git repo as well
|
// If we have an ignore path, make sure it is in a git repo as well
|
||||||
GitSearchResult::GitIgnore(ignorepath) => match search_for_git_root(&curdir)? {
|
GitSearchResult::GitIgnore(ignorepath) => match search_for_git_root(&curdir)? {
|
||||||
GitSearchResult::Git(gitpath) => GitActions::AddPattern {
|
GitSearchResult::Git(_gitpath) => GitActions::AddPattern {
|
||||||
git_path: gitpath,
|
|
||||||
gitignore_path: ignorepath,
|
gitignore_path: ignorepath,
|
||||||
},
|
},
|
||||||
_ => return Err(eyre::anyhow!("could not find parent git directory")),
|
_ => return Err(eyre::anyhow!("could not find parent git directory")),
|
||||||
@ -80,10 +74,7 @@ fn add_gitignore_pattern(term: console::Term, pattern: &String) -> eyre::Result<
|
|||||||
};
|
};
|
||||||
|
|
||||||
match actions {
|
match actions {
|
||||||
GitActions::AddPattern {
|
GitActions::AddPattern { gitignore_path } => {
|
||||||
git_path,
|
|
||||||
gitignore_path,
|
|
||||||
} => {
|
|
||||||
term.write_line("Found existing .gitignore")?;
|
term.write_line("Found existing .gitignore")?;
|
||||||
let mut gitignore_file = open_gitignore_file(&gitignore_path)?;
|
let mut gitignore_file = open_gitignore_file(&gitignore_path)?;
|
||||||
let mut gitignore_content = String::new();
|
let mut gitignore_content = String::new();
|
||||||
|
5
git-alias/git-ignore
Executable file
5
git-alias/git-ignore
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
gitignore $@
|
8
scripts/install-git-alias.sh
Executable file
8
scripts/install-git-alias.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mkdir ~/.git-bins
|
||||||
|
cp git-alias/git-ignore ~/.git-bins/git-ignore
|
||||||
|
|
||||||
|
echo "Make sure to add ~/.git-bins to your PATH"
|
Loading…
Reference in New Issue
Block a user