diff --git a/bootstrap/cache/.gitignore b/bootstrap/cache/.gitignore index e69de29bb2..d6b7ef32c8 100644 --- a/bootstrap/cache/.gitignore +++ b/bootstrap/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/logs/.gitignore b/logs/.gitignore index e69de29bb2..5e7d2734cf 100644 --- a/logs/.gitignore +++ b/logs/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/rrd/.gitignore b/rrd/.gitignore index e69de29bb2..5e7d2734cf 100644 --- a/rrd/.gitignore +++ b/rrd/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/scripts/github-remove b/scripts/github-remove index c8aa58ae52..9732a763e7 100755 --- a/scripts/github-remove +++ b/scripts/github-remove @@ -32,13 +32,25 @@ args = parser.parse_args() if args.discard: if confirm("Are you sure you want to delete all modified and untracked files?"): dirs = ["app/", "bootstrap/", "contrib/", "database/", "doc/", "html/", "includes/", "LibreNMS/", - "licenses/", "mibs/", "misc/", "resources/", "routes", "scripts/", "sql-schema/", "tests/"] + "licenses/", "mibs/", "misc/", "resources/", "routes", "scripts/", "sql-schema/", "tests/"] + gitignores = ['.gitignore', + 'bootstrap/cache/.gitignore', + 'logs/.gitignore', + 'rrd/.gitignore', + 'storage/app/.gitignore', + 'storage/app/public/.gitignore', + 'storage/debugbar/.gitignore', + 'storage/framework/cache/.gitignore', + 'storage/framework/sessions/.gitignore', + 'storage/framework/testing/.gitignore', + 'storage/framework/views/.gitignore', + 'storage/logs/.gitignore'] call(["git", "reset", "-q"], cwd=librenms_dir) call(["git", "checkout", "."], cwd=librenms_dir) call(["git", "clean", "-d", "-f"] + dirs, cwd=librenms_dir) # fix messed up gitignore file modes - call(["git", "checkout", "bootstrap/cache/.gitignore", "storage/app/.gitignore", "storage/app/public/.gitignore", "storage/debugbar/.gitignore", "storage/framework/cache/.gitignore", "storage/framework/sessions/.gitignore", "storage/framework/testing/.gitignore", "storage/framework/views/.gitignore", "storage/logs/.gitignore"]) + call(["git", "checkout"] + gitignores, cwd=librenms_dir) if args.vendor: call(["git", "clean", "-x", "-d", "-f", "vendor/"], cwd=librenms_dir) diff --git a/storage/app/.gitignore b/storage/app/.gitignore index e69de29bb2..8f4803c056 100644 --- a/storage/app/.gitignore +++ b/storage/app/.gitignore @@ -0,0 +1,3 @@ +* +!public/ +!.gitignore diff --git a/storage/app/public/.gitignore b/storage/app/public/.gitignore index e69de29bb2..d6b7ef32c8 100644 --- a/storage/app/public/.gitignore +++ b/storage/app/public/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/debugbar/.gitignore b/storage/debugbar/.gitignore index e69de29bb2..d6b7ef32c8 100644 --- a/storage/debugbar/.gitignore +++ b/storage/debugbar/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/framework/cache/.gitignore b/storage/framework/cache/.gitignore index e69de29bb2..d6b7ef32c8 100644 --- a/storage/framework/cache/.gitignore +++ b/storage/framework/cache/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/framework/sessions/.gitignore b/storage/framework/sessions/.gitignore index e69de29bb2..d6b7ef32c8 100644 --- a/storage/framework/sessions/.gitignore +++ b/storage/framework/sessions/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/framework/testing/.gitignore b/storage/framework/testing/.gitignore index e69de29bb2..d6b7ef32c8 100644 --- a/storage/framework/testing/.gitignore +++ b/storage/framework/testing/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/framework/views/.gitignore b/storage/framework/views/.gitignore index e69de29bb2..d6b7ef32c8 100644 --- a/storage/framework/views/.gitignore +++ b/storage/framework/views/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/storage/logs/.gitignore b/storage/logs/.gitignore index e69de29bb2..d6b7ef32c8 100644 --- a/storage/logs/.gitignore +++ b/storage/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/GitIgnoreTest.php b/tests/GitIgnoreTest.php new file mode 100644 index 0000000000..0ce317537a --- /dev/null +++ b/tests/GitIgnoreTest.php @@ -0,0 +1,67 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2019 Tony Murray + * @author Tony Murray + */ + +namespace LibreNMS\Tests; + +class GitIgnoreTest extends TestCase +{ + private $gitIgnoreFiles = [ + '.gitignore', + 'bootstrap/cache/.gitignore', + 'cache/.gitignore', + 'logs/.gitignore', + 'resources/views/alerts/templates/.gitignore', + 'rrd/.gitignore', + 'storage/app/.gitignore', + 'storage/app/public/.gitignore', + 'storage/debugbar/.gitignore', + 'storage/framework/cache/.gitignore', + 'storage/framework/sessions/.gitignore', + 'storage/framework/testing/.gitignore', + 'storage/framework/views/.gitignore', + 'storage/logs/.gitignore', + ]; + + public function testGitIgnoresExist() + { + foreach ($this->gitIgnoreFiles as $file) { + $this->assertFileExists($file); + } + } + + public function testGitIgnoresMode() + { + foreach ($this->gitIgnoreFiles as $file) { + $this->assertFalse(is_executable($file), "$file should not be executable"); + } + } + + public function testGitIgnoresNotEmpty() + { + foreach ($this->gitIgnoreFiles as $file) { + $this->assertGreaterThan(4, filesize($file), "$file is empty, it should not be"); + } + } +}