Added a .gitignore
file for migration folder (#1334)
* added .gitignore file * add .gitignore * only add .gitignore if not in a existing git repo * Use `git2` to detect git repository --------- Co-authored-by: Billy Chan <ccw.billy.123@gmail.com>
This commit is contained in:
parent
619f20de19
commit
3a5707b1bb
@ -45,6 +45,7 @@ tracing = { version = "0.1", default-features = false }
|
||||
url = { version = "2.2", default-features = false }
|
||||
chrono = { version = "0.4.20", default-features = false, features = ["clock"] }
|
||||
regex = { version = "1", default-features = false }
|
||||
git2 = { version = "0.16", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
smol = "1.2.5"
|
||||
|
@ -89,6 +89,10 @@ pub fn run_migrate_init(migration_dir: &str) -> Result<(), Box<dyn Error>> {
|
||||
let fn_content = |content: String| content;
|
||||
write_file!($filename, $filename, fn_content);
|
||||
};
|
||||
($filename: literal, $template: literal) => {
|
||||
let fn_content = |content: String| content;
|
||||
write_file!($filename, $template, fn_content);
|
||||
};
|
||||
($filename: literal, $template: literal, $fn_content: expr) => {
|
||||
let filepath = [&migration_dir, $filename].join("");
|
||||
println!("Creating file `{}`", filepath);
|
||||
@ -113,6 +117,9 @@ pub fn run_migrate_init(migration_dir: &str) -> Result<(), Box<dyn Error>> {
|
||||
content.replace("<sea-orm-migration-version>", &ver)
|
||||
});
|
||||
write_file!("README.md");
|
||||
if git2::Repository::discover(Path::new(&migration_dir)).is_ok() {
|
||||
write_file!(".gitignore", "_gitignore");
|
||||
}
|
||||
println!("Done!");
|
||||
|
||||
Ok(())
|
||||
|
1
sea-orm-cli/template/migration/_gitignore
Normal file
1
sea-orm-cli/template/migration/_gitignore
Normal file
@ -0,0 +1 @@
|
||||
/target
|
Loading…
x
Reference in New Issue
Block a user