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

Merge duplicated imports in finally-generated Dangerfile #631

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

417-72KI
Copy link
Member

@417-72KI 417-72KI commented Nov 11, 2024

Dividing files using // fileImport: is a very useful feature on Danger-Swift.

However, importing module in extracted file may causes an error.

Example

Dangerfile.swift

import Danger

let danger = Danger()

do {
  // fileImport: DangerExtensions/SomeFeature.swift
  try doSomething(danger, file: "path/to/file")
} catch {
  logger.error(error)
  danger.fail(error.localizedDescription)
}

DangerExtensions/SomeFeature.swift

import Danger // - error: declaration is only valid at file scope

func doSomething(_ danger: DangerDSL, filePath: String) throws {
  // ...
}

This PR makes it to merge duplicated module imports and declare at the top on generated _tmp_dangerfile.swift.

@417-72KI 417-72KI changed the title Merge dupulicated imports in finally-generated Dangerfile Merge duplicated imports in finally-generated Dangerfile Nov 11, 2024
@417-72KI 417-72KI marked this pull request as ready for review November 11, 2024 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant