commands: fix issues based on feedback

* Exit `migrate import --no-rewrite` if attributes filter
has no elements in its Include() list
* In `--no-rewrite` tests checking errors, fail out of test if
the command doesn't fail
This commit is contained in:
Preben Ingvaldsen 2018-05-31 11:19:45 -07:00
parent 77ebf9b144
commit 30cdf66a21
2 changed files with 4 additions and 2 deletions

@ -49,7 +49,7 @@ func migrateImportCommand(cmd *cobra.Command, args []string) {
root := commit.TreeID root := commit.TreeID
filter := git.GetAttributeFilter(cfg.LocalWorkingDir(), cfg.LocalGitDir()) filter := git.GetAttributeFilter(cfg.LocalWorkingDir(), cfg.LocalGitDir())
if len(filter.Include()) == 0 && len(filter.Exclude()) == 0 { if len(filter.Include()) == 0 {
ExitWithError(errors.Errorf("fatal: no Git LFS filters found in .gitattributes")) ExitWithError(errors.Errorf("fatal: no Git LFS filters found in .gitattributes"))
} }

@ -114,6 +114,7 @@ begin_test "migrate import --no-rewrite (no .gitattributes)"
git lfs migrate import --no-rewrite *.txt *.md 2>&1 | tee migrate.log git lfs migrate import --no-rewrite *.txt *.md 2>&1 | tee migrate.log
if [ ${PIPESTATUS[0]} -eq 0 ]; then if [ ${PIPESTATUS[0]} -eq 0 ]; then
echo >&2 "fatal: expected git lfs migrate import --no-rewrite to fail, didn't" echo >&2 "fatal: expected git lfs migrate import --no-rewrite to fail, didn't"
exit 1
fi fi
grep "no Git LFS filters found in .gitattributes" migrate.log grep "no Git LFS filters found in .gitattributes" migrate.log
@ -154,6 +155,7 @@ begin_test "migrate import --no-rewrite (nested .gitattributes)"
git lfs migrate import --no-rewrite a.md 2>&1 | tee migrate.log git lfs migrate import --no-rewrite a.md 2>&1 | tee migrate.log
if [ ${PIPESTATUS[0]} -eq 0 ]; then if [ ${PIPESTATUS[0]} -eq 0 ]; then
echo >&2 "fatal: expected git lfs migrate import --no-rewrite to fail, didn't" echo >&2 "fatal: expected git lfs migrate import --no-rewrite to fail, didn't"
exit 1
fi fi
grep "a.md did not match any Git LFS filters in .gitattributes" migrate.log grep "a.md did not match any Git LFS filters in .gitattributes" migrate.log