Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for .slugignore #18

Merged
merged 3 commits into from
Aug 20, 2021
Merged

Add support for .slugignore #18

merged 3 commits into from
Aug 20, 2021

Conversation

CGA1123
Copy link
Owner

@CGA1123 CGA1123 commented Aug 20, 2021

Closes: #9

Adds support for .slugignore files. prepare will now only copy files which do not match any entry in the .slugignore file for a given source-dir.

The logic is intended to follow logic similar to this:

      lines = File.read(slugignore_path).split
      total = lines.inject(0) do |total, line|
        line = (line.split(/#/).first || "").strip
        if line.empty?
          total
        else
          globs = if line =~ /\//
                    [File.join(build_dir, line)]
                  else
                    # 1.8.7 and 1.9.2 handle expanding ** differently,
                    # where in 1.9.2 ** doesn't match the empty case. So
                    # try empty ** explicitly
                    ["", "**"].map { |g| File.join(build_dir, g, line) }
                  end

          to_delete = Dir[*globs].uniq.map { |p| File.expand_path(p) }
          to_delete = to_delete.select { |p| p.match(/^#{build_dir}/) }
          to_delete.each { |p| FileUtils.rm_rf(p) }
          total + to_delete.size
        end
      end

Which as far as I can tell has not changes since Heroku closed-source their compiler, which can be verified by extracting the builder source from Heroku via a custom buildpack.

@CGA1123 CGA1123 self-assigned this Aug 20, 2021
@CGA1123 CGA1123 added the run-acceptance-tests Trigger a PR to run acceptance test suite label Aug 20, 2021
@CGA1123 CGA1123 added run-acceptance-tests Trigger a PR to run acceptance test suite and removed run-acceptance-tests Trigger a PR to run acceptance test suite labels Aug 20, 2021
@CGA1123 CGA1123 merged commit a510838 into main Aug 20, 2021
@CGA1123 CGA1123 deleted the slugignore branch August 20, 2021 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-acceptance-tests Trigger a PR to run acceptance test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support .slugignore
1 participant