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 }
|
url = { version = "2.2", default-features = false }
|
||||||
chrono = { version = "0.4.20", default-features = false, features = ["clock"] }
|
chrono = { version = "0.4.20", default-features = false, features = ["clock"] }
|
||||||
regex = { version = "1", default-features = false }
|
regex = { version = "1", default-features = false }
|
||||||
|
git2 = { version = "0.16", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
smol = "1.2.5"
|
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;
|
let fn_content = |content: String| content;
|
||||||
write_file!($filename, $filename, fn_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) => {
|
($filename: literal, $template: literal, $fn_content: expr) => {
|
||||||
let filepath = [&migration_dir, $filename].join("");
|
let filepath = [&migration_dir, $filename].join("");
|
||||||
println!("Creating file `{}`", filepath);
|
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)
|
content.replace("<sea-orm-migration-version>", &ver)
|
||||||
});
|
});
|
||||||
write_file!("README.md");
|
write_file!("README.md");
|
||||||
|
if git2::Repository::discover(Path::new(&migration_dir)).is_ok() {
|
||||||
|
write_file!(".gitignore", "_gitignore");
|
||||||
|
}
|
||||||
println!("Done!");
|
println!("Done!");
|
||||||
|
|
||||||
Ok(())
|
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