├── .dockerignore ├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ ├── create_release.yml │ └── publish_package.yml ├── .gitignore ├── .swift-version ├── .swiftlint.yml ├── .vscode └── settings.json ├── CHANGELOG.md ├── Dangerfile.swift ├── DangerfileExtensions └── ChangelogCheck.swift ├── DangerfileWithDependencies.swift ├── Dockerfile ├── Documentation ├── guides │ ├── about_the_dangerfile.html.md │ └── faq.html.md ├── reference │ ├── BitBucketCloud.md │ ├── BitBucketCloud_Activity.md │ ├── BitBucketCloud_Comment.md │ ├── BitBucketCloud_Comment_CodingKeys.md │ ├── BitBucketCloud_Comment_Inline.md │ ├── BitBucketCloud_Commit.md │ ├── BitBucketCloud_Commit_Author.md │ ├── BitBucketCloud_Commit_Parent.md │ ├── BitBucketCloud_Content.md │ ├── BitBucketCloud_MergeRef.md │ ├── BitBucketCloud_MergeRef_Branch.md │ ├── BitBucketCloud_MergeRef_Commit.md │ ├── BitBucketCloud_PullRequest.md │ ├── BitBucketCloud_PullRequest_CodingKeys.md │ ├── BitBucketCloud_PullRequest_Participant.md │ ├── BitBucketCloud_PullRequest_Participant_Role.md │ ├── BitBucketCloud_PullRequest_State.md │ ├── BitBucketCloud_Repo.md │ ├── BitBucketCloud_Repo_CodingKeys.md │ ├── BitBucketCloud_User.md │ ├── BitBucketCloud_User_CodingKeys.md │ ├── BitBucketMetadata.md │ ├── BitBucketServer.md │ ├── BitBucketServer_Activity.md │ ├── BitBucketServer_Activity_CodingKeys.md │ ├── BitBucketServer_Comment.md │ ├── BitBucketServer_Comment_CodingKeys.md │ ├── BitBucketServer_Comment_Detail.md │ ├── BitBucketServer_Comment_Detail_CodingKeys.md │ ├── BitBucketServer_Comment_Detail_InnerProperties.md │ ├── BitBucketServer_Comment_Detail_Task.md │ ├── BitBucketServer_Comment_Detail_Task_CodingKeys.md │ ├── BitBucketServer_Commit.md │ ├── BitBucketServer_Commit_Parent.md │ ├── BitBucketServer_MergeRef.md │ ├── BitBucketServer_Project.md │ ├── BitBucketServer_Project_CodingKeys.md │ ├── BitBucketServer_PullRequest.md │ ├── BitBucketServer_PullRequest_CodingKeys.md │ ├── BitBucketServer_PullRequest_Participant.md │ ├── BitBucketServer_PullRequest_Reviewer.md │ ├── BitBucketServer_Repo.md │ ├── BitBucketServer_Repo_CodingKeys.md │ ├── BitBucketServer_User.md │ ├── DSL.md │ ├── Danger().md │ ├── Danger.swift │ ├── DangerDSL.md │ ├── DangerUtils.md │ ├── DangerUtils_Environment.md │ ├── DangerUtils_Environment_Value.md │ ├── DateFormatter.md │ ├── File.md │ ├── FileDiff.md │ ├── FileDiff_Changes.md │ ├── FileDiff_Hunk.md │ ├── FileDiff_Line.md │ ├── FileType.md │ ├── Git.md │ ├── GitHub.md │ ├── GitHub_Commit.md │ ├── GitHub_Commit_CodingKeys.md │ ├── GitHub_Commit_CommitData.md │ ├── GitHub_Issue.md │ ├── GitHub_Issue_CodingKeys.md │ ├── GitHub_Issue_Label.md │ ├── GitHub_Issue_State.md │ ├── GitHub_MergeRef.md │ ├── GitHub_Milestone.md │ ├── GitHub_Milestone_CodingKeys.md │ ├── GitHub_Milestone_State.md │ ├── GitHub_PullRequest.md │ ├── GitHub_PullRequest_CodingKeys.md │ ├── GitHub_PullRequest_Link.md │ ├── GitHub_PullRequest_Link_CodingKeys.md │ ├── GitHub_PullRequest_Link_Relation.md │ ├── GitHub_PullRequest_PullRequestState.md │ ├── GitHub_Repo.md │ ├── GitHub_Repo_CodingKeys.md │ ├── GitHub_RequestedReviewers.md │ ├── GitHub_Review.md │ ├── GitHub_Review_CodingKeys.md │ ├── GitHub_Review_State.md │ ├── GitHub_Team.md │ ├── GitHub_User.md │ ├── GitHub_User_CodingKeys.md │ ├── GitHub_User_UserType.md │ ├── GitLab.md │ ├── GitLab_CodingKeys.md │ ├── GitLab_MergeRequest.md │ ├── GitLab_MergeRequest_CodingKeys.md │ ├── GitLab_MergeRequest_DiffRefs.md │ ├── GitLab_MergeRequest_DiffRefs_CodingKeys.md │ ├── GitLab_MergeRequest_Milestone.md │ ├── GitLab_MergeRequest_Milestone_CodingKeys.md │ ├── GitLab_MergeRequest_Milestone_ParentIdentifier.md │ ├── GitLab_MergeRequest_Milestone_ParentIdentifier_Error.md │ ├── GitLab_MergeRequest_Milestone_State.md │ ├── GitLab_MergeRequest_Pipeline.md │ ├── GitLab_MergeRequest_Pipeline_CodingKeys.md │ ├── GitLab_MergeRequest_Pipeline_Status.md │ ├── GitLab_MergeRequest_State.md │ ├── GitLab_MergeRequest_TimeStats.md │ ├── GitLab_MergeRequest_TimeStats_CodingKeys.md │ ├── GitLab_MergeRequest_UserMergeData.md │ ├── GitLab_MergeRequest_UserMergeData_CodingKeys.md │ ├── GitLab_Metadata.md │ ├── GitLab_User.md │ ├── GitLab_User_CodingKeys.md │ ├── GitLab_User_State.md │ ├── Git_Commit.md │ ├── Git_Commit_Author.md │ ├── Home.md │ ├── Meta.md │ ├── Optional.md │ ├── SwiftLint.md │ ├── SwiftLintViolation.md │ ├── SwiftLintViolation_Severity.md │ ├── SwiftLint_LintStyle.md │ ├── SwiftLint_SwiftlintPath.md │ ├── Violation.md │ ├── _Footer.md │ ├── _Sidebar.md │ ├── fail(_:).md │ ├── fail(message:file:line:).md │ ├── fails.md │ ├── markdown(_:).md │ ├── markdown(message:file:line:).md │ ├── markdowns.md │ ├── message(_:).md │ ├── message(message:file:line:).md │ ├── messages.md │ ├── suggestion(code:file:line:).md │ ├── warn(_:).md │ ├── warn(message:file:line:).md │ └── warnings.md ├── tutorials │ ├── architecture.html.md │ ├── fast_feedback.html.md │ ├── images │ │ └── swift-edit.png │ ├── ios_app.html.md │ └── migrating_from_ruby_danger.html.md └── usage │ ├── bitbucket.html.md │ ├── bitbucket_cloud.html.md │ ├── culture.html.md │ ├── extending_danger.html.md │ ├── extending_danger_two.html.md │ └── gitlab.html.md ├── LICENSE ├── Makefile ├── Package.resolved ├── Package.swift ├── README.md ├── Scripts ├── change_is_develop.sh ├── create_homebrew_tap.sh ├── data │ └── request.template.yml ├── install.sh ├── release_changelog.sh ├── release_swiftlint_docker.sh ├── update_changelog.sh ├── update_danger_version.sh ├── update_docs.rb └── update_makefile.sh ├── Sources ├── Danger-Swift │ └── Fake.swift ├── Danger │ ├── BitBucketCloud.swift │ ├── BitBucketMetadata.swift │ ├── BitBucketServerDSL.swift │ ├── Danger.swift │ ├── DangerDSL.swift │ ├── DangerResults.swift │ ├── DangerUtils.swift │ ├── Extensions │ │ ├── DateFormatterExtensions.swift │ │ └── NSRegularExpressionExtensions.swift │ ├── File.swift │ ├── GitDSL.swift │ ├── GitDiff.swift │ ├── GitHubDSL.swift │ ├── GitLabDSL.swift │ ├── Plugins │ │ └── SwiftLint │ │ │ ├── CurrentPathProvider.swift │ │ │ ├── SwiftLint.swift │ │ │ ├── SwiftLintViolation.swift │ │ │ └── SwiftlintReportDeleter.swift │ ├── Report.swift │ └── Settings.swift ├── DangerDependenciesResolver │ ├── Data+Encoding.swift │ ├── FileCreator.swift │ ├── FileReader.swift │ ├── InlineDependenciesFinder.swift │ ├── Package.swift │ ├── PackageDataProvider.swift │ ├── PackageGenerator.swift │ ├── PackageListMaker.swift │ ├── PackageManager.swift │ ├── Script.swift │ └── URL+RemoteRepository.swift ├── DangerFixtures │ ├── DangerDSLResources │ │ ├── CustomGitHubDSL.swift │ │ ├── DSLBitBucketCloudJSON.swift │ │ ├── DSLGitLabGroupMilestone.swift │ │ ├── DSLGitLabProjectMilestone.swift │ │ ├── DangerDLSBitBucketServer.swift │ │ ├── DangerDLSBitBucketServerForkedRepo.swift │ │ ├── DangerDSLGitHub.swift │ │ ├── DangerDSLGitHubEnterprise.swift │ │ ├── DangerDSLGitLab.swift │ │ └── DangerDSLGitLabMilestoneNoDateRange.swift │ └── DangerFixtures.swift ├── DangerShellExecutor │ └── ShellExecutor.swift ├── Runner │ ├── Commands │ │ ├── Edit.swift │ │ ├── RunDangerJS.swift │ │ └── Runner.swift │ ├── MarathonScriptManager.swift │ └── main.swift └── RunnerLib │ ├── CliArgs │ ├── CliArgs.swift │ └── CliArgsParser.swift │ ├── DangerCommand.swift │ ├── DangerJSVersionFinder.swift │ ├── DangerSwiftOption.swift │ ├── DangerfileArgumentsPath.swift │ ├── Files Import │ ├── DangerFileGenerator.swift │ └── ImportsFinder.swift │ ├── GetDangerJSPath.swift │ ├── HelpMessagePresenter.swift │ ├── NSRegularExpression+FilesImport.swift │ ├── Runtime.swift │ ├── SPMDanger.swift │ ├── String+Path.swift │ └── VersionChecker.swift ├── Tests ├── DangerDependenciesResolverTests │ ├── InlineDependenciesFinderTests.swift │ ├── PackageDataProviderTests.swift │ ├── PackageGeneratorTests.swift │ ├── PackageListMakerTests.swift │ ├── StubbedDataReader.swift │ └── __Snapshots__ │ │ └── PackageGeneratorTests │ │ ├── testGeneratedDescriptionHeader.1.txt │ │ ├── testGeneratedPackageWhenThereAreDependencies.1.txt │ │ ├── testGeneratedPackageWhenThereAreDependenciesAndSwiftVersionIs5_2.1.txt │ │ ├── testGeneratedPackageWhenThereAreDependenciesAndSwiftVersionIs5_6.1.txt │ │ └── testGeneratedPackageWhenThereAreNoDependencies.1.txt ├── DangerTests │ ├── BitBucketCloudTests.swift │ ├── BitBucketServerTestResources │ │ ├── BitBucketServerProject.swift │ │ ├── BitBucketServerRepo.swift │ │ └── BitBucketServerUser.swift │ ├── BitBucketServerTests.swift │ ├── BitbucketCloudResources │ │ ├── BitbucketCloudCommentUserWithoutAccountIdAndNickname.swift │ │ └── BitbucketCloudCommit.swift │ ├── DangerDSLTests.swift │ ├── DangerUtilsLineSearchTests.swift │ ├── DangerUtilsTests.swift │ ├── DateFormatterExtensionTests.swift │ ├── DateFormatterHandlerTests.swift │ ├── DefaultDateFormatterTests.swift │ ├── FileTests.swift │ ├── FileTypeTests.swift │ ├── GitDiffTests.swift │ ├── GitHubTestResources │ │ ├── GitHubBot.swift │ │ ├── GitHubCommit.swift │ │ ├── GitHubIssue.swift │ │ ├── GitHubMilestone.swift │ │ ├── GitHubPR.swift │ │ ├── GitHubRepo.swift │ │ ├── GitHubReviews.swift │ │ ├── GitHubTeam.swift │ │ └── GitHubUser.swift │ ├── GitHubTests.swift │ ├── GitLabMilestoneTests.swift │ ├── GitLabTests.swift │ ├── GitTests.swift │ ├── NSRegularExpressionExtensionsTests.swift │ ├── OnlyDateDateFormatterTests.swift │ └── SwiftLint │ │ ├── DangerSwiftLintTests.swift │ │ ├── FakeCurrentPathProvider.swift │ │ ├── FakeShellExecutor.swift │ │ ├── SwiftlintDefaultPathTests.swift │ │ ├── SwiftlintReportDeleterTests.swift │ │ └── ViolationTests.swift └── RunnerLibTests │ ├── CliParserTests.swift │ ├── DangerCommandTests.swift │ ├── DangerFileGeneratorTests.swift │ ├── DangerJSVersionFinderTests.swift │ ├── DangerfilePathFinderTests.swift │ ├── GetDangerJSPathTests.swift │ ├── HelpMessagePresenterTests.swift │ ├── ImportsFinderTests.swift │ ├── MockedExecutor.swift │ ├── SPMDangerTests.swift │ ├── StringPathExtensionTests.swift │ ├── VersionCheckerTests.swift │ └── __Snapshots__ │ └── DangerFileGeneratorTests │ ├── testItGeneratesTheCorrectFileWhenOneOfTheImportedFilesIsMissing.1.txt │ ├── testItGeneratesTheCorrectFileWhenThereAreNoImports.1.txt │ ├── testItGeneratesTheCorrectFileWhenThereIsASingleImport.1.txt │ ├── testItGeneratesTheCorrectFileWhenThereIsAreImportsWithIndent.1.txt │ └── testItGeneratesTheCorrectFileWhenThereIsAreMultipleImports.1.txt ├── fixtures └── eidolon_609.json └── package.json /.dockerignore: -------------------------------------------------------------------------------- 1 | # .dockerignore 2 | .build 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [f-meloni] 2 | -------------------------------------------------------------------------------- /.github/workflows/create_release.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Create Release 4 | 5 | # Controls when the workflow will run 6 | on: 7 | push: 8 | tags: 9 | - '*' 10 | 11 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v2 17 | 18 | - name: Export tag version 19 | run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV 20 | 21 | - name: Create release 22 | run: ./Scripts/release_changelog.sh 23 | env: 24 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 | -------------------------------------------------------------------------------- /.github/workflows/publish_package.yml: -------------------------------------------------------------------------------- 1 | name: Release Danger-Swift package 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | 15 | - name: Export tag version 16 | run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV 17 | 18 | - name: Docker Login 19 | run: echo $PACKAGES_WRITE_TOKEN | docker login ghcr.io -u $USERNAME --password-stdin 20 | env: 21 | PACKAGES_WRITE_TOKEN: ${{ secrets.DOCKER_GITHUB_PASSWORD }} 22 | USERNAME: ${{ secrets.DOCKER_GITHUB_USERNAME }} 23 | 24 | - name: Docker Build 25 | run: docker build -t ghcr.io/danger/danger-swift:$VERSION . 26 | 27 | - name: Deploy 28 | run: docker push ghcr.io/danger/danger-swift:$VERSION 29 | 30 | - name: Update Dockerfile to create image with Swiftlint 31 | run: Scripts/release_swiftlint_docker.sh 32 | 33 | - name: Docker Build 34 | run: docker build -t ghcr.io/danger/danger-swift-with-swiftlint:$VERSION . 35 | 36 | - name: Deploy 37 | run: docker push ghcr.io/danger/danger-swift-with-swiftlint:$VERSION 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | .derivedData/ 7 | build/ 8 | DerivedData/ 9 | /*.tar.gz 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | .swiftpm 22 | 23 | ## Other 24 | *.moved-aside 25 | *.xccheckout 26 | *.xcscmblueprint 27 | 28 | ## Obj-C/Swift specific 29 | *.hmap 30 | *.ipa 31 | *.dSYM.zip 32 | *.dSYM 33 | 34 | ## Playgrounds 35 | timeline.xctimeline 36 | playground.xcworkspace 37 | 38 | # Swift Package Manager 39 | # 40 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 41 | # Packages/ 42 | # Package.pins 43 | .build/ 44 | 45 | # CocoaPods 46 | # 47 | # We recommend against adding the Pods directory to your .gitignore. However 48 | # you should judge for yourself, the pros and cons are mentioned at: 49 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 50 | # 51 | # Pods/ 52 | 53 | # Carthage 54 | # 55 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 56 | # Carthage/Checkouts 57 | 58 | Carthage/Build 59 | 60 | # fastlane 61 | # 62 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 63 | # screenshots whenever they are needed. 64 | # For more information about the recommended setup visit: 65 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 66 | 67 | fastlane/report.xml 68 | fastlane/Preview.html 69 | fastlane/screenshots 70 | fastlane/test_output 71 | 72 | Danger/.build 73 | *.xcodeproj 74 | .build 75 | Fixtures/response_data.json 76 | 77 | Scripts/data/request.yml 78 | Scripts/tmp/* 79 | !Scripts/tmp/.gitkeep 80 | 81 | yarn.lock 82 | node_modules 83 | .DS_Store 84 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 5.10 2 | -------------------------------------------------------------------------------- /.swiftlint.yml: -------------------------------------------------------------------------------- 1 | included: 2 | - Sources 3 | - Tests 4 | excluded: 5 | - Tests/**/*Resources # files in this directory contains only JSON strings. 6 | - Tests/**/XCTestManifests.swift # auto-generated file 7 | line_length: 8 | warning: 140 # needs discussion (default: 120) 9 | error: 350 # needs discussion (default: 200) 10 | ignores_comments: true 11 | ignores_urls: true 12 | ignores_function_declarations: true 13 | ignores_interpolated_strings: true 14 | identifier_name: 15 | excluded: 16 | - ci 17 | - id 18 | - pr 19 | disabled_rules: 20 | - trailing_comma 21 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/.git": true, 4 | "**/.DS_Store": true, 5 | "**/.build": true, 6 | "**/danger-swift.xcodeproj": true 7 | }, 8 | "cSpell.words": [ 9 | "Xcode", 10 | "bitbucket", 11 | "struct" 12 | ], 13 | "editor.formatOnSave": true, 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Dangerfile.swift: -------------------------------------------------------------------------------- 1 | import Danger 2 | import Foundation 3 | 4 | let danger = Danger() 5 | 6 | // fileImport: DangerfileExtensions/ChangelogCheck.swift 7 | checkChangelog() 8 | 9 | if danger.git.createdFiles.count + danger.git.modifiedFiles.count - danger.git.deletedFiles.count > 300 { 10 | warn("Big PR, try to keep changes smaller if you can") 11 | } 12 | 13 | let swiftFilesWithCopyright = danger.git.createdFiles.filter { 14 | $0.fileType == .swift 15 | && danger.utils.readFile($0).contains("// Created by") 16 | } 17 | 18 | if !swiftFilesWithCopyright.isEmpty { 19 | let files = swiftFilesWithCopyright.joined(separator: ", ") 20 | warn("In Danger JS we don't include copyright headers, found them in: \(files)") 21 | } 22 | 23 | let filesToLint = (danger.git.modifiedFiles + danger.git.createdFiles).filter { !$0.contains("Documentation/") } 24 | 25 | SwiftLint.lint(.files(filesToLint), inline: true) 26 | 27 | // Support running via `danger local` 28 | if danger.github != nil { 29 | // These checks only happen on a PR 30 | if danger.github.pullRequest.title.contains("WIP") { 31 | warn("PR is classed as Work in Progress") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /DangerfileExtensions/ChangelogCheck.swift: -------------------------------------------------------------------------------- 1 | import Danger 2 | 3 | func checkChangelog() { 4 | let allSourceFiles = danger.git.modifiedFiles + danger.git.createdFiles 5 | 6 | let changelogChanged = allSourceFiles.contains("CHANGELOG.md") 7 | let sourceChanges = allSourceFiles.first(where: { $0.hasPrefix("Sources") }) 8 | 9 | let isTrivial = (danger.github != nil) && danger.github.pullRequest.title.contains("#trivial") 10 | 11 | if !isTrivial, !changelogChanged, sourceChanges != nil { 12 | danger.warn(""" 13 | Any changes to library code should be reflected in the Changelog. 14 | 15 | Please consider adding a note there and adhere to the [Changelog Guidelines](https://github.com/Moya/contributors/blob/master/Changelog%20Guidelines.md). 16 | """) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DangerfileWithDependencies.swift: -------------------------------------------------------------------------------- 1 | import Danger 2 | import DangerXCodeSummary // package: https://github.com/f-meloni/danger-swift-xcodesummary.git 3 | 4 | let danger = Danger() 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ARG SWIFT_VERSION=5.9 2 | FROM swift:${SWIFT_VERSION}-focal 3 | 4 | LABEL org.opencontainers.image.authors="Orta Therox" 5 | 6 | LABEL "com.github.actions.name"="Danger Swift" 7 | LABEL "com.github.actions.description"="Runs Swift Dangerfiles" 8 | LABEL "com.github.actions.icon"="zap" 9 | LABEL "com.github.actions.color"="blue" 10 | 11 | # Install nodejs and Danger 12 | RUN apt-get update -q \ 13 | && apt-get install -qy curl make ca-certificates \ 14 | && curl -sL https://deb.nodesource.com/setup_18.x | bash - \ 15 | && apt-get install -qy nodejs \ 16 | && npm install -g danger \ 17 | && rm -r /var/lib/apt/lists/* 18 | 19 | 20 | # RUN git clone -b 0.50.3 --single-branch --depth 1 https://github.com/realm/SwiftLint.git _swiftlint && cd _swiftlint && git submodule update --init --recursive && make install && rm -rf _swiftlint # swiftlint 21 | 22 | # Install danger-swift globally 23 | COPY . _danger-swift 24 | RUN cd _danger-swift && make install && rm -rf _danger-swift 25 | 26 | # Run Danger Swift via Danger JS, allowing for custom args 27 | ENTRYPOINT ["danger-swift", "ci"] 28 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud 2 | 3 | ``` swift 4 | public struct BitBucketCloud:​ Decodable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable` 10 | 11 | ## Properties 12 | 13 | ### `activities` 14 | 15 | The activities such as OPENING, CLOSING, MERGING or UPDATING a pull request 16 | 17 | ``` swift 18 | let activities:​ [Activity] 19 | ``` 20 | 21 | ### `comments` 22 | 23 | The comments on the pull request 24 | 25 | ``` swift 26 | let comments:​ [Comment] 27 | ``` 28 | 29 | ### `commits` 30 | 31 | The commits associated with the pull request 32 | 33 | ``` swift 34 | let commits:​ [Commit] 35 | ``` 36 | 37 | ### `metadata` 38 | 39 | The pull request and repository metadata 40 | 41 | ``` swift 42 | let metadata:​ BitBucketMetadata 43 | ``` 44 | 45 | ### `pr` 46 | 47 | The PR metadata 48 | 49 | ``` swift 50 | let pr:​ PullRequest 51 | ``` 52 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Activity.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Activity 2 | 3 | ``` swift 4 | struct Activity:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `comment` 14 | 15 | ``` swift 16 | let comment:​ Comment? 17 | ``` 18 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Comment.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Comment 2 | 3 | ``` swift 4 | struct Comment:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `content` 14 | 15 | Content of the comment 16 | 17 | ``` swift 18 | let content:​ Content 19 | ``` 20 | 21 | ### `createdOn` 22 | 23 | When the comment was created 24 | 25 | ``` swift 26 | let createdOn:​ Date 27 | ``` 28 | 29 | ### `deleted` 30 | 31 | Was the comment deleted? 32 | 33 | ``` swift 34 | let deleted:​ Bool 35 | ``` 36 | 37 | ### `id` 38 | 39 | ``` swift 40 | let id:​ Int 41 | ``` 42 | 43 | ### `inline` 44 | 45 | ``` swift 46 | let inline:​ Inline? 47 | ``` 48 | 49 | ### `type` 50 | 51 | ``` swift 52 | let type:​ String 53 | ``` 54 | 55 | ### `updatedOn` 56 | 57 | When the comment was updated 58 | 59 | ``` swift 60 | let updatedOn:​ Date 61 | ``` 62 | 63 | ### `user` 64 | 65 | The user that created the comment 66 | 67 | ``` swift 68 | let user:​ User 69 | ``` 70 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Comment_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Comment.CodingKeys 2 | 3 | ``` swift 4 | private enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `deleted` 14 | 15 | ``` swift 16 | case deleted 17 | ``` 18 | 19 | ### `content` 20 | 21 | ``` swift 22 | case content 23 | ``` 24 | 25 | ### `createdOn` 26 | 27 | ``` swift 28 | case createdOn 29 | ``` 30 | 31 | ### `user` 32 | 33 | ``` swift 34 | case user 35 | ``` 36 | 37 | ### `updatedOn` 38 | 39 | ``` swift 40 | case updatedOn 41 | ``` 42 | 43 | ### `type` 44 | 45 | ``` swift 46 | case type 47 | ``` 48 | 49 | ### `id` 50 | 51 | ``` swift 52 | case id 53 | ``` 54 | 55 | ### `inline` 56 | 57 | ``` swift 58 | case inline 59 | ``` 60 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Comment_Inline.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Comment.Inline 2 | 3 | ``` swift 4 | public struct Inline:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `from` 14 | 15 | ``` swift 16 | let from:​ Int? 17 | ``` 18 | 19 | ### `to` 20 | 21 | ``` swift 22 | let to:​ Int? 23 | ``` 24 | 25 | ### `path` 26 | 27 | ``` swift 28 | let path:​ String? 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Commit.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Commit 2 | 3 | ``` swift 4 | struct Commit:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `author` 14 | 15 | The author of the commit, assumed to be the person who wrote the code. 16 | 17 | ``` swift 18 | let author:​ Author 19 | ``` 20 | 21 | ### `date` 22 | 23 | When the commit was commited to the project 24 | 25 | ``` swift 26 | let date:​ Date 27 | ``` 28 | 29 | ### `hash` 30 | 31 | The SHA for the commit 32 | 33 | ``` swift 34 | let hash:​ String 35 | ``` 36 | 37 | ### `message` 38 | 39 | The commit's message 40 | 41 | ``` swift 42 | let message:​ String 43 | ``` 44 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Commit_Author.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Commit.Author 2 | 3 | ``` swift 4 | public struct Author:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `raw` 14 | 15 | Format:​ `Foo Bar ` 16 | 17 | ``` swift 18 | let raw:​ String 19 | ``` 20 | 21 | ### `user` 22 | 23 | The user that created the commit 24 | 25 | ``` swift 26 | let user:​ User? 27 | ``` 28 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Commit_Parent.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Commit.Parent 2 | 3 | ``` swift 4 | public struct Parent 5 | ``` 6 | 7 | ## Properties 8 | 9 | ### `hash` 10 | 11 | The full SHA 12 | 13 | ``` swift 14 | let hash:​ String 15 | ``` 16 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Content.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Content 2 | 3 | ``` swift 4 | struct Content:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `html` 14 | 15 | ``` swift 16 | let html:​ String 17 | ``` 18 | 19 | ### `markup` 20 | 21 | ``` swift 22 | let markup:​ String 23 | ``` 24 | 25 | ### `raw` 26 | 27 | ``` swift 28 | let raw:​ String 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_MergeRef.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.MergeRef 2 | 3 | ``` swift 4 | struct MergeRef:​ Decodable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable` 10 | 11 | ## Properties 12 | 13 | ### `branch` 14 | 15 | ``` swift 16 | let branch:​ Branch 17 | ``` 18 | 19 | ### `branchName` 20 | 21 | ``` swift 22 | var branchName:​ String 23 | ``` 24 | 25 | ### `commit` 26 | 27 | ``` swift 28 | let commit:​ Commit 29 | ``` 30 | 31 | ### `commitHash` 32 | 33 | Hash of the last commit 34 | 35 | ``` swift 36 | var commitHash:​ String 37 | ``` 38 | 39 | ### `repository` 40 | 41 | ``` swift 42 | let repository:​ Repo 43 | ``` 44 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_MergeRef_Branch.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.MergeRef.Branch 2 | 3 | ``` swift 4 | private struct Branch:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `name` 14 | 15 | ``` swift 16 | let name:​ String 17 | ``` 18 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_MergeRef_Commit.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.MergeRef.Commit 2 | 3 | ``` swift 4 | private struct Commit:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `hash` 14 | 15 | ``` swift 16 | let hash:​ String 17 | ``` 18 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_PullRequest.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.PullRequest 2 | 3 | ``` swift 4 | struct PullRequest:​ Decodable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable` 10 | 11 | ## Properties 12 | 13 | ### `author` 14 | 15 | The creator of the PR 16 | 17 | ``` swift 18 | let author:​ User 19 | ``` 20 | 21 | ### `createdOn` 22 | 23 | Date when PR was created 24 | 25 | ``` swift 26 | let createdOn:​ Date 27 | ``` 28 | 29 | ### `description` 30 | 31 | The text describing the PR 32 | 33 | ``` swift 34 | let description:​ String 35 | ``` 36 | 37 | ### `destination` 38 | 39 | The PR's destination 40 | 41 | ``` swift 42 | let destination:​ MergeRef 43 | ``` 44 | 45 | ### `id` 46 | 47 | PR's ID 48 | 49 | ``` swift 50 | let id:​ Int 51 | ``` 52 | 53 | ### `participants` 54 | 55 | People who have participated in the PR 56 | 57 | ``` swift 58 | let participants:​ [Participant] 59 | ``` 60 | 61 | ### `reviewers` 62 | 63 | People requested as reviewers 64 | 65 | ``` swift 66 | let reviewers:​ [User] 67 | ``` 68 | 69 | ### `source` 70 | 71 | The PR's source, The repo Danger is running on 72 | 73 | ``` swift 74 | let source:​ MergeRef 75 | ``` 76 | 77 | ### `state` 78 | 79 | The pull request's current status. 80 | 81 | ``` swift 82 | let state:​ State 83 | ``` 84 | 85 | ### `title` 86 | 87 | Title of the pull request 88 | 89 | ``` swift 90 | let title:​ String 91 | ``` 92 | 93 | ### `updatedOn` 94 | 95 | Date of last update 96 | 97 | ``` swift 98 | let updatedOn:​ Date 99 | ``` 100 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_PullRequest_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.PullRequest.CodingKeys 2 | 3 | ``` swift 4 | private enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `author` 14 | 15 | ``` swift 16 | case author 17 | ``` 18 | 19 | ### `createdOn` 20 | 21 | ``` swift 22 | case createdOn 23 | ``` 24 | 25 | ### `description` 26 | 27 | ``` swift 28 | case description 29 | ``` 30 | 31 | ### `destination` 32 | 33 | ``` swift 34 | case destination 35 | ``` 36 | 37 | ### `id` 38 | 39 | ``` swift 40 | case id 41 | ``` 42 | 43 | ### `participants` 44 | 45 | ``` swift 46 | case participants 47 | ``` 48 | 49 | ### `reviewers` 50 | 51 | ``` swift 52 | case reviewers 53 | ``` 54 | 55 | ### `source` 56 | 57 | ``` swift 58 | case source 59 | ``` 60 | 61 | ### `state` 62 | 63 | ``` swift 64 | case state 65 | ``` 66 | 67 | ### `title` 68 | 69 | ``` swift 70 | case title 71 | ``` 72 | 73 | ### `updatedOn` 74 | 75 | ``` swift 76 | case updatedOn 77 | ``` 78 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_PullRequest_Participant.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.PullRequest.Participant 2 | 3 | ``` swift 4 | public struct Participant:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `approved` 14 | 15 | Did they approve of the PR? 16 | 17 | ``` swift 18 | let approved:​ Bool 19 | ``` 20 | 21 | ### `role` 22 | 23 | How did they contribute 24 | 25 | ``` swift 26 | let role:​ Role 27 | ``` 28 | 29 | ### `user` 30 | 31 | The user who participated in this PR 32 | 33 | ``` swift 34 | let user:​ User 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_PullRequest_Participant_Role.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.PullRequest.Participant.Role 2 | 3 | ``` swift 4 | public enum Role 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `reviewer` 14 | 15 | ``` swift 16 | case reviewer 17 | ``` 18 | 19 | ### `participant` 20 | 21 | ``` swift 22 | case participant 23 | ``` 24 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_PullRequest_State.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.PullRequest.State 2 | 3 | ``` swift 4 | public enum State 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `declined` 14 | 15 | ``` swift 16 | case declined 17 | ``` 18 | 19 | ### `merged` 20 | 21 | ``` swift 22 | case merged 23 | ``` 24 | 25 | ### `open` 26 | 27 | ``` swift 28 | case open 29 | ``` 30 | 31 | ### `suspended` 32 | 33 | ``` swift 34 | case suspended 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Repo.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Repo 2 | 3 | ``` swift 4 | struct Repo:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `fullName` 14 | 15 | ``` swift 16 | let fullName:​ String 17 | ``` 18 | 19 | ### `name` 20 | 21 | ``` swift 22 | let name:​ String 23 | ``` 24 | 25 | ### `uuid` 26 | 27 | The uuid of the repository 28 | 29 | ``` swift 30 | let uuid:​ String 31 | ``` 32 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_Repo_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.Repo.CodingKeys 2 | 3 | ``` swift 4 | private enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `fullName` 14 | 15 | ``` swift 16 | case fullName 17 | ``` 18 | 19 | ### `name` 20 | 21 | ``` swift 22 | case name 23 | ``` 24 | 25 | ### `uuid` 26 | 27 | ``` swift 28 | case uuid 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_User.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.User 2 | 3 | ``` swift 4 | struct User:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `accountId` 14 | 15 | The acount id of the user 16 | 17 | ``` swift 18 | let accountId:​ String? 19 | ``` 20 | 21 | ### `displayName` 22 | 23 | The display name of user 24 | 25 | ``` swift 26 | let displayName:​ String 27 | ``` 28 | 29 | ### `nickname` 30 | 31 | The nick name of the user 32 | 33 | ``` swift 34 | let nickname:​ String? 35 | ``` 36 | 37 | ### `uuid` 38 | 39 | The uuid of the user 40 | 41 | ``` swift 42 | let uuid:​ String 43 | ``` 44 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketCloud_User_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketCloud.User.CodingKeys 2 | 3 | ``` swift 4 | private enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `accountId` 14 | 15 | ``` swift 16 | case accountId 17 | ``` 18 | 19 | ### `displayName` 20 | 21 | ``` swift 22 | case displayName 23 | ``` 24 | 25 | ### `nickname` 26 | 27 | ``` swift 28 | case nickname 29 | ``` 30 | 31 | ### `uuid` 32 | 33 | ``` swift 34 | case uuid 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketMetadata.md: -------------------------------------------------------------------------------- 1 | # BitBucketMetadata 2 | 3 | ``` swift 4 | public struct BitBucketMetadata:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `pullRequestID` 14 | 15 | The PR's ID 16 | 17 | ``` swift 18 | var pullRequestID:​ String 19 | ``` 20 | 21 | ### `repoSlug` 22 | 23 | The complete repo slug including project slug. 24 | 25 | ``` swift 26 | var repoSlug:​ String 27 | ``` 28 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer 2 | 3 | ``` swift 4 | public struct BitBucketServer:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `metadata` 14 | 15 | The pull request and repository metadata 16 | 17 | ``` swift 18 | let metadata:​ BitBucketMetadata 19 | ``` 20 | 21 | ### `pullRequest` 22 | 23 | The pull request metadata 24 | 25 | ``` swift 26 | let pullRequest:​ PullRequest 27 | ``` 28 | 29 | ### `commits` 30 | 31 | The commits associated with the pull request 32 | 33 | ``` swift 34 | let commits:​ [Commit] 35 | ``` 36 | 37 | ### `comments` 38 | 39 | The comments on the pull request 40 | 41 | ``` swift 42 | let comments:​ [Comment] 43 | ``` 44 | 45 | ### `activities` 46 | 47 | The activities such as OPENING, CLOSING, MERGING or UPDATING a pull request 48 | 49 | ``` swift 50 | let activities:​ [Activity] 51 | ``` 52 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Activity.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Activity 2 | 3 | ``` swift 4 | struct Activity:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The activity's ID 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `createdAt` 22 | 23 | Date activity created as number of mili seconds since the unix epoch 24 | 25 | ``` swift 26 | let createdAt:​ Int 27 | ``` 28 | 29 | ### `user` 30 | 31 | The user that triggered the activity. 32 | 33 | ``` swift 34 | let user:​ User 35 | ``` 36 | 37 | ### `action` 38 | 39 | The action the activity describes (e.g. "COMMENTED"). 40 | 41 | ``` swift 42 | let action:​ String 43 | ``` 44 | 45 | ### `commentAction` 46 | 47 | In case the action was "COMMENTED" it will state the command specific action (e.g. "CREATED"). 48 | 49 | ``` swift 50 | let commentAction:​ String? 51 | ``` 52 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Activity_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Activity.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `createdAt` 20 | 21 | ``` swift 22 | case createdAt 23 | ``` 24 | 25 | ### `user` 26 | 27 | ``` swift 28 | case user 29 | ``` 30 | 31 | ### `action` 32 | 33 | ``` swift 34 | case action 35 | ``` 36 | 37 | ### `commentAction` 38 | 39 | ``` swift 40 | case commentAction 41 | ``` 42 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Comment.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Comment 2 | 3 | ``` swift 4 | struct Comment:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The comment's id 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `createdAt` 22 | 23 | Date comment created as number of mili seconds since the unix epoch 24 | 25 | ``` swift 26 | let createdAt:​ Int 27 | ``` 28 | 29 | ### `user` 30 | 31 | The comment's author 32 | 33 | ``` swift 34 | let user:​ User 35 | ``` 36 | 37 | ### `action` 38 | 39 | The action the user did (e.g. "COMMENTED") 40 | 41 | ``` swift 42 | let action:​ String 43 | ``` 44 | 45 | ### `fromHash` 46 | 47 | The SHA to which the comment was created 48 | 49 | ``` swift 50 | let fromHash:​ String? 51 | ``` 52 | 53 | ### `previousFromHash` 54 | 55 | The previous SHA to which the comment was created 56 | 57 | ``` swift 58 | let previousFromHash:​ String? 59 | ``` 60 | 61 | ### `toHash` 62 | 63 | The next SHA after the comment was created 64 | 65 | ``` swift 66 | let toHash:​ String? 67 | ``` 68 | 69 | ### `previousToHash` 70 | 71 | The SHA to which the comment was created 72 | 73 | ``` swift 74 | let previousToHash:​ String? 75 | ``` 76 | 77 | ### `commentAction` 78 | 79 | Action the user did (e.g. "ADDED") if it is a new task 80 | 81 | ``` swift 82 | let commentAction:​ String? 83 | ``` 84 | 85 | ### `comment` 86 | 87 | Detailed data of the comment 88 | 89 | ``` swift 90 | let comment:​ Detail? 91 | ``` 92 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Comment_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Comment.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `createdAt` 20 | 21 | ``` swift 22 | case createdAt 23 | ``` 24 | 25 | ### `user` 26 | 27 | ``` swift 28 | case user 29 | ``` 30 | 31 | ### `action` 32 | 33 | ``` swift 34 | case action 35 | ``` 36 | 37 | ### `fromHash` 38 | 39 | ``` swift 40 | case fromHash 41 | ``` 42 | 43 | ### `previousFromHash` 44 | 45 | ``` swift 46 | case previousFromHash 47 | ``` 48 | 49 | ### `toHash` 50 | 51 | ``` swift 52 | case toHash 53 | ``` 54 | 55 | ### `previousToHash` 56 | 57 | ``` swift 58 | case previousToHash 59 | ``` 60 | 61 | ### `commentAction` 62 | 63 | ``` swift 64 | case commentAction 65 | ``` 66 | 67 | ### `comment` 68 | 69 | ``` swift 70 | case comment 71 | ``` 72 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Comment_Detail.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Comment.Detail 2 | 3 | ``` swift 4 | public struct Detail:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The comment's id 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `version` 22 | 23 | The comment's version 24 | 25 | ``` swift 26 | let version:​ Int 27 | ``` 28 | 29 | ### `text` 30 | 31 | The comment content 32 | 33 | ``` swift 34 | let text:​ String 35 | ``` 36 | 37 | ### `author` 38 | 39 | The author of the comment 40 | 41 | ``` swift 42 | let author:​ User 43 | ``` 44 | 45 | ### `createdAt` 46 | 47 | Date comment created as number of mili seconds since the unix epoch 48 | 49 | ``` swift 50 | let createdAt:​ Int 51 | ``` 52 | 53 | ### `updatedAt` 54 | 55 | Date comment updated as number of mili seconds since the unix epoch 56 | 57 | ``` swift 58 | let updatedAt:​ Int 59 | ``` 60 | 61 | ### `comments` 62 | 63 | Replys to the comment 64 | 65 | ``` swift 66 | let comments:​ [Detail] 67 | ``` 68 | 69 | ### `properties` 70 | 71 | Properties associated with the comment 72 | 73 | ``` swift 74 | let properties:​ InnerProperties 75 | ``` 76 | 77 | ### `tasks` 78 | 79 | Tasks associated with the comment 80 | 81 | ``` swift 82 | let tasks:​ [Task] 83 | ``` 84 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Comment_Detail_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Comment.Detail.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `version` 20 | 21 | ``` swift 22 | case version 23 | ``` 24 | 25 | ### `text` 26 | 27 | ``` swift 28 | case text 29 | ``` 30 | 31 | ### `author` 32 | 33 | ``` swift 34 | case author 35 | ``` 36 | 37 | ### `createdAt` 38 | 39 | ``` swift 40 | case createdAt 41 | ``` 42 | 43 | ### `updatedAt` 44 | 45 | ``` swift 46 | case updatedAt 47 | ``` 48 | 49 | ### `comments` 50 | 51 | ``` swift 52 | case comments 53 | ``` 54 | 55 | ### `properties` 56 | 57 | ``` swift 58 | case properties 59 | ``` 60 | 61 | ### `tasks` 62 | 63 | ``` swift 64 | case tasks 65 | ``` 66 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Comment_Detail_InnerProperties.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Comment.Detail.InnerProperties 2 | 3 | ``` swift 4 | public struct InnerProperties:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `repositoryId` 14 | 15 | The ID of the repo 16 | 17 | ``` swift 18 | let repositoryId:​ Int 19 | ``` 20 | 21 | ### `issues` 22 | 23 | Slugs of linkd Jira issues 24 | 25 | ``` swift 26 | let issues:​ [String]? 27 | ``` 28 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Comment_Detail_Task.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Comment.Detail.Task 2 | 3 | ``` swift 4 | public struct Task:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The tasks ID 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `createdAt` 22 | 23 | Date activity created as number of mili seconds since the unix epoch 24 | 25 | ``` swift 26 | let createdAt:​ Int 27 | ``` 28 | 29 | ### `text` 30 | 31 | The text of the task 32 | 33 | ``` swift 34 | let text:​ String 35 | ``` 36 | 37 | ### `state` 38 | 39 | The state of the task (e.g. "OPEN") 40 | 41 | ``` swift 42 | let state:​ String 43 | ``` 44 | 45 | ### `author` 46 | 47 | The author of the comment 48 | 49 | ``` swift 50 | let author:​ User 51 | ``` 52 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Comment_Detail_Task_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Comment.Detail.Task.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `createdAt` 20 | 21 | ``` swift 22 | case createdAt 23 | ``` 24 | 25 | ### `text` 26 | 27 | ``` swift 28 | case text 29 | ``` 30 | 31 | ### `state` 32 | 33 | ``` swift 34 | case state 35 | ``` 36 | 37 | ### `author` 38 | 39 | ``` swift 40 | case author 41 | ``` 42 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Commit.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Commit 2 | 3 | ``` swift 4 | struct Commit:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The SHA for the commit 16 | 17 | ``` swift 18 | let id:​ String 19 | ``` 20 | 21 | ### `displayId` 22 | 23 | The shortened SHA for the commit 24 | 25 | ``` swift 26 | let displayId:​ String 27 | ``` 28 | 29 | ### `author` 30 | 31 | The author of the commit, assumed to be the person who wrote the code. 32 | 33 | ``` swift 34 | let author:​ User 35 | ``` 36 | 37 | ### `authorTimestamp` 38 | 39 | The UNIX timestamp for when the commit was authored 40 | 41 | ``` swift 42 | let authorTimestamp:​ Int 43 | ``` 44 | 45 | ### `committer` 46 | 47 | The author of the commit, assumed to be the person who commited/merged the code into a project. 48 | 49 | ``` swift 50 | let committer:​ User? 51 | ``` 52 | 53 | ### `committerTimestamp` 54 | 55 | When the commit was commited to the project 56 | 57 | ``` swift 58 | let committerTimestamp:​ Int? 59 | ``` 60 | 61 | ### `message` 62 | 63 | The commit's message 64 | 65 | ``` swift 66 | let message:​ String 67 | ``` 68 | 69 | ### `parents` 70 | 71 | The commit's parents 72 | 73 | ``` swift 74 | let parents:​ [Parent] 75 | ``` 76 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Commit_Parent.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Commit.Parent 2 | 3 | ``` swift 4 | public struct Parent:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The SHA for the commit 16 | 17 | ``` swift 18 | let id:​ String 19 | ``` 20 | 21 | ### `displayId` 22 | 23 | The shortened SHA for the commit 24 | 25 | ``` swift 26 | let displayId:​ String 27 | ``` 28 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_MergeRef.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.MergeRef 2 | 3 | ``` swift 4 | struct MergeRef:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The branch name 16 | 17 | ``` swift 18 | let id:​ String 19 | ``` 20 | 21 | ### `displayId` 22 | 23 | The human readable branch name 24 | 25 | ``` swift 26 | let displayId:​ String 27 | ``` 28 | 29 | ### `latestCommit` 30 | 31 | The SHA for the latest commit 32 | 33 | ``` swift 34 | let latestCommit:​ String 35 | ``` 36 | 37 | ### `repository` 38 | 39 | Info of the associated repository 40 | 41 | ``` swift 42 | let repository:​ Repo 43 | ``` 44 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Project.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Project 2 | 3 | ``` swift 4 | struct Project:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The project unique id 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `key` 22 | 23 | The project's human readable project key 24 | 25 | ``` swift 26 | let key:​ String 27 | ``` 28 | 29 | ### `name` 30 | 31 | The name of the project 32 | 33 | ``` swift 34 | let name:​ String 35 | ``` 36 | 37 | ### `isPublic` 38 | 39 | Is the project publicly available 40 | 41 | ``` swift 42 | let isPublic:​ Bool 43 | ``` 44 | 45 | ### `type` 46 | 47 | ``` swift 48 | let type:​ String 49 | ``` 50 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Project_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Project.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `key` 20 | 21 | ``` swift 22 | case key 23 | ``` 24 | 25 | ### `name` 26 | 27 | ``` swift 28 | case name 29 | ``` 30 | 31 | ### `isPublic` 32 | 33 | ``` swift 34 | case isPublic 35 | ``` 36 | 37 | ### `type` 38 | 39 | ``` swift 40 | case type 41 | ``` 42 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_PullRequest.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.PullRequest 2 | 3 | ``` swift 4 | struct PullRequest:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The PR's ID 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `version` 22 | 23 | The API version 24 | 25 | ``` swift 26 | let version:​ Int 27 | ``` 28 | 29 | ### `title` 30 | 31 | Title of the pull request. 32 | 33 | ``` swift 34 | let title:​ String 35 | ``` 36 | 37 | ### `description` 38 | 39 | The description of the PR 40 | 41 | ``` swift 42 | let description:​ String? 43 | ``` 44 | 45 | ### `state` 46 | 47 | The pull request's current status. 48 | 49 | ``` swift 50 | let state:​ String 51 | ``` 52 | 53 | ### `open` 54 | 55 | Is PR open? 56 | 57 | ``` swift 58 | let open:​ Bool 59 | ``` 60 | 61 | ### `closed` 62 | 63 | Is PR closed? 64 | 65 | ``` swift 66 | let closed:​ Bool 67 | ``` 68 | 69 | ### `createdAt` 70 | 71 | Date PR created as number of mili seconds since the unix epoch 72 | 73 | ``` swift 74 | let createdAt:​ Int 75 | ``` 76 | 77 | ### `updatedAt` 78 | 79 | Date PR updated as number of mili seconds since the unix epoch 80 | 81 | ``` swift 82 | let updatedAt:​ Int? 83 | ``` 84 | 85 | ### `fromRef` 86 | 87 | The PR submittor's reference 88 | 89 | ``` swift 90 | let fromRef:​ MergeRef 91 | ``` 92 | 93 | ### `toRef` 94 | 95 | The repo Danger is running on 96 | 97 | ``` swift 98 | let toRef:​ MergeRef 99 | ``` 100 | 101 | ### `isLocked` 102 | 103 | Is the PR locked? 104 | 105 | ``` swift 106 | let isLocked:​ Bool 107 | ``` 108 | 109 | ### `author` 110 | 111 | The creator of the PR 112 | 113 | ``` swift 114 | let author:​ Participant 115 | ``` 116 | 117 | ### `reviewers` 118 | 119 | People requested as reviewers 120 | 121 | ``` swift 122 | let reviewers:​ [Reviewer] 123 | ``` 124 | 125 | ### `participants` 126 | 127 | People who have participated in the PR 128 | 129 | ``` swift 130 | let participants:​ [Participant] 131 | ``` 132 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_PullRequest_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.PullRequest.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `version` 20 | 21 | ``` swift 22 | case version 23 | ``` 24 | 25 | ### `title` 26 | 27 | ``` swift 28 | case title 29 | ``` 30 | 31 | ### `description` 32 | 33 | ``` swift 34 | case description 35 | ``` 36 | 37 | ### `state` 38 | 39 | ``` swift 40 | case state 41 | ``` 42 | 43 | ### `open` 44 | 45 | ``` swift 46 | case open 47 | ``` 48 | 49 | ### `closed` 50 | 51 | ``` swift 52 | case closed 53 | ``` 54 | 55 | ### `createdAt` 56 | 57 | ``` swift 58 | case createdAt 59 | ``` 60 | 61 | ### `updatedAt` 62 | 63 | ``` swift 64 | case updatedAt 65 | ``` 66 | 67 | ### `fromRef` 68 | 69 | ``` swift 70 | case fromRef 71 | ``` 72 | 73 | ### `toRef` 74 | 75 | ``` swift 76 | case toRef 77 | ``` 78 | 79 | ### `isLocked` 80 | 81 | ``` swift 82 | case isLocked 83 | ``` 84 | 85 | ### `author` 86 | 87 | ``` swift 88 | case author 89 | ``` 90 | 91 | ### `reviewers` 92 | 93 | ``` swift 94 | case reviewers 95 | ``` 96 | 97 | ### `participants` 98 | 99 | ``` swift 100 | case participants 101 | ``` 102 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_PullRequest_Participant.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.PullRequest.Participant 2 | 3 | A user that is parecipating in the PR 4 | 5 | ``` swift 6 | public struct Participant:​ Decodable, Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `user` 16 | 17 | The BitBucket Server User 18 | 19 | ``` swift 20 | let user:​ User 21 | ``` 22 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_PullRequest_Reviewer.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.PullRequest.Reviewer 2 | 3 | A user that reviewed the PR 4 | 5 | ``` swift 6 | public struct Reviewer:​ Decodable, Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `user` 16 | 17 | The BitBucket Server User 18 | 19 | ``` swift 20 | let user:​ User 21 | ``` 22 | 23 | ### `approved` 24 | 25 | The approval status 26 | 27 | ``` swift 28 | let approved:​ Bool 29 | ``` 30 | 31 | ### `lastReviewedCommit` 32 | 33 | The commit SHA for the latest commit that was reviewed 34 | 35 | ``` swift 36 | let lastReviewedCommit:​ String? 37 | ``` 38 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Repo.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Repo 2 | 3 | ``` swift 4 | struct Repo:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `name` 14 | 15 | The repo name 16 | 17 | ``` swift 18 | let name:​ String? 19 | ``` 20 | 21 | ### `slug` 22 | 23 | The slug for the repo 24 | 25 | ``` swift 26 | let slug:​ String 27 | ``` 28 | 29 | ### `scmId` 30 | 31 | The type of SCM tool, probably "git" 32 | 33 | ``` swift 34 | let scmId:​ String 35 | ``` 36 | 37 | ### `isPublic` 38 | 39 | Is the repo public? 40 | 41 | ``` swift 42 | let isPublic:​ Bool 43 | ``` 44 | 45 | ### `forkable` 46 | 47 | Can someone fork thie repo? 48 | 49 | ``` swift 50 | let forkable:​ Bool 51 | ``` 52 | 53 | ### `project` 54 | 55 | An abtraction for grouping repos 56 | 57 | ``` swift 58 | let project:​ Project 59 | ``` 60 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_Repo_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.Repo.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `name` 14 | 15 | ``` swift 16 | case name 17 | ``` 18 | 19 | ### `slug` 20 | 21 | ``` swift 22 | case slug 23 | ``` 24 | 25 | ### `scmId` 26 | 27 | ``` swift 28 | case scmId 29 | ``` 30 | 31 | ### `isPublic` 32 | 33 | ``` swift 34 | case isPublic 35 | ``` 36 | 37 | ### `forkable` 38 | 39 | ``` swift 40 | case forkable 41 | ``` 42 | 43 | ### `project` 44 | 45 | ``` swift 46 | case project 47 | ``` 48 | -------------------------------------------------------------------------------- /Documentation/reference/BitBucketServer_User.md: -------------------------------------------------------------------------------- 1 | # BitBucketServer.User 2 | 3 | ``` swift 4 | struct User:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The unique user ID 16 | 17 | ``` swift 18 | let id:​ Int? 19 | ``` 20 | 21 | ### `name` 22 | 23 | The name of the user 24 | 25 | ``` swift 26 | let name:​ String 27 | ``` 28 | 29 | ### `displayName` 30 | 31 | The name to use when referencing the user 32 | 33 | ``` swift 34 | let displayName:​ String? 35 | ``` 36 | 37 | ### `emailAddress` 38 | 39 | The email for the user 40 | 41 | ``` swift 42 | let emailAddress:​ String? 43 | ``` 44 | 45 | ### `active` 46 | 47 | Is the account active 48 | 49 | ``` swift 50 | let active:​ Bool? 51 | ``` 52 | 53 | ### `slug` 54 | 55 | The user's slug for URLs 56 | 57 | ``` swift 58 | let slug:​ String? 59 | ``` 60 | 61 | ### `type` 62 | 63 | The type of a user, "NORMAL" being a typical user3 64 | 65 | ``` swift 66 | let type:​ String? 67 | ``` 68 | -------------------------------------------------------------------------------- /Documentation/reference/DSL.md: -------------------------------------------------------------------------------- 1 | # DSL 2 | 3 | ``` swift 4 | public struct DSL:​ Decodable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable` 10 | 11 | ## Properties 12 | 13 | ### `danger` 14 | 15 | The root danger import 16 | 17 | ``` swift 18 | let danger:​ DangerDSL 19 | ``` 20 | -------------------------------------------------------------------------------- /Documentation/reference/Danger().md: -------------------------------------------------------------------------------- 1 | # Danger() 2 | 3 | ``` swift 4 | public func Danger() -> DangerDSL 5 | ``` 6 | -------------------------------------------------------------------------------- /Documentation/reference/Danger.swift: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Documentation/reference/DangerUtils_Environment.md: -------------------------------------------------------------------------------- 1 | # DangerUtils.Environment 2 | 3 | ``` swift 4 | @dynamicMemberLookup struct Environment 5 | ``` 6 | 7 | ## Initializers 8 | 9 | ### `init(env:​)` 10 | 11 | ``` swift 12 | init(env:​ @escaping () -> [String:​ String] = { ProcessInfo.processInfo.environment }) 13 | ``` 14 | 15 | ## Properties 16 | 17 | ### `env` 18 | 19 | ``` swift 20 | let env:​ () -> [String:​ String] 21 | ``` 22 | -------------------------------------------------------------------------------- /Documentation/reference/DangerUtils_Environment_Value.md: -------------------------------------------------------------------------------- 1 | # DangerUtils.Environment.Value 2 | 3 | ``` swift 4 | enum Value 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CustomStringConvertible`, `Equatable` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `boolean` 14 | 15 | ``` swift 16 | case boolean(:​ Bool) 17 | ``` 18 | 19 | ### `string` 20 | 21 | ``` swift 22 | case string(:​ String) 23 | ``` 24 | 25 | ## Properties 26 | 27 | ### `description` 28 | 29 | ``` swift 30 | var description:​ String 31 | ``` 32 | -------------------------------------------------------------------------------- /Documentation/reference/DateFormatter.md: -------------------------------------------------------------------------------- 1 | # Extensions on DateFormatter 2 | 3 | ## Properties 4 | 5 | ### `defaultDateFormatter` 6 | 7 | ``` swift 8 | public static var defaultDateFormatter: DateFormatter 9 | ``` 10 | 11 | ### `onlyDateDateFormatter` 12 | 13 | ``` swift 14 | public static var onlyDateDateFormatter: DateFormatter 15 | ``` 16 | 17 | ## Methods 18 | 19 | ### `dateFormatterHandler(_:)` 20 | 21 | Handles multiple date format inside models. 22 | 23 | ``` swift 24 | public static func dateFormatterHandler(_ decoder: Decoder) throws -> Date 25 | ``` 26 | -------------------------------------------------------------------------------- /Documentation/reference/File.md: -------------------------------------------------------------------------------- 1 | # File 2 | 3 | A simple typealias for strings representing files 4 | 5 | ``` swift 6 | public typealias File = String 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/FileDiff.md: -------------------------------------------------------------------------------- 1 | # FileDiff 2 | 3 | ``` swift 4 | public struct FileDiff:​ Equatable, CustomStringConvertible 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CustomStringConvertible`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `filePath` 14 | 15 | ``` swift 16 | var filePath:​ String 17 | ``` 18 | 19 | ### `changes` 20 | 21 | ``` swift 22 | var changes:​ Changes 23 | ``` 24 | 25 | ### `description` 26 | 27 | ``` swift 28 | var description:​ String 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/FileDiff_Changes.md: -------------------------------------------------------------------------------- 1 | # FileDiff.Changes 2 | 3 | ``` swift 4 | enum Changes 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Equatable` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `created` 14 | 15 | ``` swift 16 | case created(addedLines:​ [String]) 17 | ``` 18 | 19 | ### `deleted` 20 | 21 | ``` swift 22 | case deleted(deletedLines:​ [String]) 23 | ``` 24 | 25 | ### `modified` 26 | 27 | ``` swift 28 | case modified(hunks:​ [Hunk]) 29 | ``` 30 | 31 | ### `renamed` 32 | 33 | ``` swift 34 | case renamed(oldPath:​ String, hunks:​ [Hunk]) 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/reference/FileDiff_Hunk.md: -------------------------------------------------------------------------------- 1 | # FileDiff.Hunk 2 | 3 | ``` swift 4 | struct Hunk:​ Equatable, CustomStringConvertible 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CustomStringConvertible`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `oldLineStart` 14 | 15 | ``` swift 16 | let oldLineStart:​ Int 17 | ``` 18 | 19 | ### `oldLineSpan` 20 | 21 | ``` swift 22 | let oldLineSpan:​ Int 23 | ``` 24 | 25 | ### `newLineStart` 26 | 27 | ``` swift 28 | let newLineStart:​ Int 29 | ``` 30 | 31 | ### `newLineSpan` 32 | 33 | ``` swift 34 | let newLineSpan:​ Int 35 | ``` 36 | 37 | ### `lines` 38 | 39 | ``` swift 40 | let lines:​ [Line] 41 | ``` 42 | 43 | ### `description` 44 | 45 | ``` swift 46 | var description:​ String 47 | ``` 48 | -------------------------------------------------------------------------------- /Documentation/reference/FileDiff_Line.md: -------------------------------------------------------------------------------- 1 | # FileDiff.Line 2 | 3 | ``` swift 4 | struct Line:​ Equatable, CustomStringConvertible 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CustomStringConvertible`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `text` 14 | 15 | ``` swift 16 | let text:​ String 17 | ``` 18 | 19 | ### `changeType` 20 | 21 | ``` swift 22 | let changeType:​ ChangeType 23 | ``` 24 | 25 | ### `description` 26 | 27 | ``` swift 28 | var description:​ String 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/FileType.md: -------------------------------------------------------------------------------- 1 | # FileType 2 | 3 | ``` swift 4 | public enum FileType 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CaseIterable`, `Equatable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `json` 14 | 15 | ``` swift 16 | case json 17 | ``` 18 | 19 | ### `swift` 20 | 21 | ``` swift 22 | case swift 23 | ``` 24 | 25 | ### `yaml` 26 | 27 | ``` swift 28 | case yaml 29 | ``` 30 | 31 | ### `pbxproj` 32 | 33 | ``` swift 34 | case pbxproj 35 | ``` 36 | 37 | ### `mm` 38 | 39 | ``` swift 40 | case mm 41 | ``` 42 | 43 | ### `plist` 44 | 45 | ``` swift 46 | case plist 47 | ``` 48 | 49 | ### `storyboard` 50 | 51 | ``` swift 52 | case storyboard 53 | ``` 54 | 55 | ### `m` 56 | 57 | ``` swift 58 | case m 59 | ``` 60 | 61 | ### `xcscheme` 62 | 63 | ``` swift 64 | case xcscheme 65 | ``` 66 | 67 | ### `yml` 68 | 69 | ``` swift 70 | case yml 71 | ``` 72 | 73 | ### `markdown` 74 | 75 | ``` swift 76 | case markdown 77 | ``` 78 | 79 | ### `h` 80 | 81 | ``` swift 82 | case h 83 | ``` 84 | 85 | ## Properties 86 | 87 | ### `` `extension` `` 88 | 89 | ``` swift 90 | var `extension`:​ String 91 | ``` 92 | -------------------------------------------------------------------------------- /Documentation/reference/Git.md: -------------------------------------------------------------------------------- 1 | # Git 2 | 3 | The git specific metadata for a pull request. 4 | 5 | ``` swift 6 | public struct Git:​ Decodable, Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `modifiedFiles` 16 | 17 | Modified filepaths relative to the git root. 18 | 19 | ``` swift 20 | let modifiedFiles:​ [File] 21 | ``` 22 | 23 | ### `createdFiles` 24 | 25 | Newly created filepaths relative to the git root. 26 | 27 | ``` swift 28 | let createdFiles:​ [File] 29 | ``` 30 | 31 | ### `deletedFiles` 32 | 33 | Removed filepaths relative to the git root. 34 | 35 | ``` swift 36 | let deletedFiles:​ [File] 37 | ``` 38 | 39 | ### `commits` 40 | 41 | ``` swift 42 | let commits:​ [Commit] 43 | ``` 44 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub.md: -------------------------------------------------------------------------------- 1 | # GitHub 2 | 3 | The GitHub metadata for your pull request. 4 | 5 | ``` swift 6 | public struct GitHub:​ Decodable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable` 12 | 13 | ## Properties 14 | 15 | ### `issue` 16 | 17 | ``` swift 18 | let issue:​ Issue 19 | ``` 20 | 21 | ### `pullRequest` 22 | 23 | ``` swift 24 | let pullRequest:​ PullRequest 25 | ``` 26 | 27 | ### `commits` 28 | 29 | ``` swift 30 | let commits:​ [Commit] 31 | ``` 32 | 33 | ### `reviews` 34 | 35 | ``` swift 36 | let reviews:​ [Review] 37 | ``` 38 | 39 | ### `requestedReviewers` 40 | 41 | ``` swift 42 | let requestedReviewers:​ RequestedReviewers 43 | ``` 44 | 45 | ### `api` 46 | 47 | ``` swift 48 | var api:​ Octokit! 49 | ``` 50 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Commit.md: -------------------------------------------------------------------------------- 1 | # GitHub.Commit 2 | 3 | A GitHub specific implementation of a git commit. 4 | 5 | ``` swift 6 | struct Commit:​ Decodable, Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Initializers 14 | 15 | ### `init(from:​)` 16 | 17 | ``` swift 18 | public init(from decoder:​ Decoder) throws 19 | ``` 20 | 21 | ## Properties 22 | 23 | ### `sha` 24 | 25 | The SHA for the commit. 26 | 27 | ``` swift 28 | let sha:​ String 29 | ``` 30 | 31 | ### `commit` 32 | 33 | The raw commit metadata. 34 | 35 | ``` swift 36 | let commit:​ CommitData 37 | ``` 38 | 39 | ### `url` 40 | 41 | The URL for the commit on GitHub. 42 | 43 | ``` swift 44 | let url:​ String 45 | ``` 46 | 47 | ### `author` 48 | 49 | The GitHub user who wrote the code. 50 | 51 | ``` swift 52 | let author:​ User? 53 | ``` 54 | 55 | ### `committer` 56 | 57 | The GitHub user who shipped the code. 58 | 59 | ``` swift 60 | let committer:​ User? 61 | ``` 62 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Commit_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitHub.Commit.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `sha` 14 | 15 | ``` swift 16 | case sha 17 | ``` 18 | 19 | ### `commit` 20 | 21 | ``` swift 22 | case commit 23 | ``` 24 | 25 | ### `url` 26 | 27 | ``` swift 28 | case url 29 | ``` 30 | 31 | ### `author` 32 | 33 | ``` swift 34 | case author 35 | ``` 36 | 37 | ### `committer` 38 | 39 | ``` swift 40 | case committer 41 | ``` 42 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Commit_CommitData.md: -------------------------------------------------------------------------------- 1 | # GitHub.Commit.CommitData 2 | 3 | A GitHub specific implementation of a github commit. 4 | 5 | ``` swift 6 | struct CommitData:​ Equatable, Decodable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `sha` 16 | 17 | The SHA for the commit. 18 | 19 | ``` swift 20 | let sha:​ String? 21 | ``` 22 | 23 | ### `author` 24 | 25 | Who wrote the commit. 26 | 27 | ``` swift 28 | let author:​ Git.Commit.Author 29 | ``` 30 | 31 | ### `committer` 32 | 33 | Who shipped the code. 34 | 35 | ``` swift 36 | let committer:​ Git.Commit.Author 37 | ``` 38 | 39 | ### `message` 40 | 41 | The message for the commit. 42 | 43 | ``` swift 44 | let message:​ String 45 | ``` 46 | 47 | ### `parents` 48 | 49 | SHAs for the commit's parents. 50 | 51 | ``` swift 52 | let parents:​ [String]? 53 | ``` 54 | 55 | ### `url` 56 | 57 | The URL for the commit. 58 | 59 | ``` swift 60 | let url:​ String 61 | ``` 62 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Issue.md: -------------------------------------------------------------------------------- 1 | # GitHub.Issue 2 | 3 | ``` swift 4 | struct Issue:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The id number of the issue 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `number` 22 | 23 | The number of the issue. 24 | 25 | ``` swift 26 | let number:​ Int 27 | ``` 28 | 29 | ### `title` 30 | 31 | The title of the issue. 32 | 33 | ``` swift 34 | let title:​ String 35 | ``` 36 | 37 | ### `user` 38 | 39 | The user who created the issue. 40 | 41 | ``` swift 42 | let user:​ User 43 | ``` 44 | 45 | ### `state` 46 | 47 | The state for the issue:​ open, closed, locked. 48 | 49 | ``` swift 50 | let state:​ State 51 | ``` 52 | 53 | ### `isLocked` 54 | 55 | A boolean indicating if the issue has been locked to contributors only. 56 | 57 | ``` swift 58 | let isLocked:​ Bool 59 | ``` 60 | 61 | ### `body` 62 | 63 | The markdown body message of the issue. 64 | 65 | ``` swift 66 | let body:​ String? 67 | ``` 68 | 69 | ### `commentCount` 70 | 71 | The comment number of comments for the issue. 72 | 73 | ``` swift 74 | let commentCount:​ Int 75 | ``` 76 | 77 | ### `assignee` 78 | 79 | The user who is assigned to the issue. 80 | 81 | ``` swift 82 | let assignee:​ User? 83 | ``` 84 | 85 | ### `assignees` 86 | 87 | The users who are assigned to the issue. 88 | 89 | ``` swift 90 | let assignees:​ [User] 91 | ``` 92 | 93 | ### `milestone` 94 | 95 | The milestone of this issue 96 | 97 | ``` swift 98 | let milestone:​ Milestone? 99 | ``` 100 | 101 | ### `createdAt` 102 | 103 | The ISO8601 date string for when the issue was created. 104 | 105 | ``` swift 106 | let createdAt:​ Date 107 | ``` 108 | 109 | ### `updatedAt` 110 | 111 | The ISO8601 date string for when the issue was updated. 112 | 113 | ``` swift 114 | let updatedAt:​ Date 115 | ``` 116 | 117 | ### `closedAt` 118 | 119 | The ISO8601 date string for when the issue was closed. 120 | 121 | ``` swift 122 | let closedAt:​ Date? 123 | ``` 124 | 125 | ### `labels` 126 | 127 | The labels associated with this issue. 128 | 129 | ``` swift 130 | let labels:​ [Label] 131 | ``` 132 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Issue_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitHub.Issue.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `number` 20 | 21 | ``` swift 22 | case number 23 | ``` 24 | 25 | ### `title` 26 | 27 | ``` swift 28 | case title 29 | ``` 30 | 31 | ### `user` 32 | 33 | ``` swift 34 | case user 35 | ``` 36 | 37 | ### `state` 38 | 39 | ``` swift 40 | case state 41 | ``` 42 | 43 | ### `assignee` 44 | 45 | ``` swift 46 | case assignee 47 | ``` 48 | 49 | ### `assignees` 50 | 51 | ``` swift 52 | case assignees 53 | ``` 54 | 55 | ### `milestone` 56 | 57 | ``` swift 58 | case milestone 59 | ``` 60 | 61 | ### `body` 62 | 63 | ``` swift 64 | case body 65 | ``` 66 | 67 | ### `labels` 68 | 69 | ``` swift 70 | case labels 71 | ``` 72 | 73 | ### `commentCount` 74 | 75 | ``` swift 76 | case commentCount 77 | ``` 78 | 79 | ### `isLocked` 80 | 81 | ``` swift 82 | case isLocked 83 | ``` 84 | 85 | ### `createdAt` 86 | 87 | ``` swift 88 | case createdAt 89 | ``` 90 | 91 | ### `updatedAt` 92 | 93 | ``` swift 94 | case updatedAt 95 | ``` 96 | 97 | ### `closedAt` 98 | 99 | ``` swift 100 | case closedAt 101 | ``` 102 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Issue_Label.md: -------------------------------------------------------------------------------- 1 | # GitHub.Issue.Label 2 | 3 | ``` swift 4 | public struct Label:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The id number of this label. 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `url` 22 | 23 | The URL that links to this label. 24 | 25 | ``` swift 26 | let url:​ String 27 | ``` 28 | 29 | ### `name` 30 | 31 | The name of the label. 32 | 33 | ``` swift 34 | let name:​ String 35 | ``` 36 | 37 | ### `color` 38 | 39 | The color associated with this label. 40 | 41 | ``` swift 42 | let color:​ String 43 | ``` 44 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Issue_State.md: -------------------------------------------------------------------------------- 1 | # GitHub.Issue.State 2 | 3 | ``` swift 4 | public enum State 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `open` 14 | 15 | ``` swift 16 | case open 17 | ``` 18 | 19 | ### `closed` 20 | 21 | ``` swift 22 | case closed 23 | ``` 24 | 25 | ### `locked` 26 | 27 | ``` swift 28 | case locked 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_MergeRef.md: -------------------------------------------------------------------------------- 1 | # GitHub.MergeRef 2 | 3 | Represents 'head' in PR 4 | 5 | ``` swift 6 | struct MergeRef:​ Decodable, Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `label` 16 | 17 | The human display name for the merge reference, e.g. "artsy:​master". 18 | 19 | ``` swift 20 | let label:​ String 21 | ``` 22 | 23 | ### `ref` 24 | 25 | The reference point for the merge, e.g. "master" 26 | 27 | ``` swift 28 | let ref:​ String 29 | ``` 30 | 31 | ### `sha` 32 | 33 | The reference point for the merge, e.g. "704dc55988c6996f69b6873c2424be7d1de67bbe" 34 | 35 | ``` swift 36 | let sha:​ String 37 | ``` 38 | 39 | ### `user` 40 | 41 | The user that owns the merge reference e.g. "artsy" 42 | 43 | ``` swift 44 | let user:​ User 45 | ``` 46 | 47 | ### `repo` 48 | 49 | The repo from which the reference comes from 50 | 51 | ``` swift 52 | let repo:​ Repo 53 | ``` 54 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Milestone.md: -------------------------------------------------------------------------------- 1 | # GitHub.Milestone 2 | 3 | ``` swift 4 | struct Milestone:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | The id number of this milestone 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `number` 22 | 23 | The number of this milestone 24 | 25 | ``` swift 26 | let number:​ Int 27 | ``` 28 | 29 | ### `state` 30 | 31 | The state of this milestone:​ open, closed, all 32 | 33 | ``` swift 34 | let state:​ State 35 | ``` 36 | 37 | ### `title` 38 | 39 | The title of this milestone 40 | 41 | ``` swift 42 | let title:​ String 43 | ``` 44 | 45 | ### `description` 46 | 47 | The description of this milestone. 48 | 49 | ``` swift 50 | let description:​ String? 51 | ``` 52 | 53 | ### `creator` 54 | 55 | The user who created this milestone. 56 | 57 | ``` swift 58 | let creator:​ User 59 | ``` 60 | 61 | ### `openIssues` 62 | 63 | The number of open issues in this milestone 64 | 65 | ``` swift 66 | let openIssues:​ Int 67 | ``` 68 | 69 | ### `closedIssues` 70 | 71 | The number of closed issues in this milestone 72 | 73 | ``` swift 74 | let closedIssues:​ Int 75 | ``` 76 | 77 | ### `createdAt` 78 | 79 | The ISO8601 date string for when this milestone was created. 80 | 81 | ``` swift 82 | let createdAt:​ Date 83 | ``` 84 | 85 | ### `updatedAt` 86 | 87 | The ISO8601 date string for when this milestone was updated. 88 | 89 | ``` swift 90 | let updatedAt:​ Date 91 | ``` 92 | 93 | ### `closedAt` 94 | 95 | The ISO8601 date string for when this milestone was closed. 96 | 97 | ``` swift 98 | let closedAt:​ Date? 99 | ``` 100 | 101 | ### `dueOn` 102 | 103 | The ISO8601 date string for the due of this milestone. 104 | 105 | ``` swift 106 | let dueOn:​ Date? 107 | ``` 108 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Milestone_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitHub.Milestone.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `closedAt` 14 | 15 | ``` swift 16 | case closedAt 17 | ``` 18 | 19 | ### `closedIssues` 20 | 21 | ``` swift 22 | case closedIssues 23 | ``` 24 | 25 | ### `createdAt` 26 | 27 | ``` swift 28 | case createdAt 29 | ``` 30 | 31 | ### `creator` 32 | 33 | ``` swift 34 | case creator 35 | ``` 36 | 37 | ### `description` 38 | 39 | ``` swift 40 | case description 41 | ``` 42 | 43 | ### `dueOn` 44 | 45 | ``` swift 46 | case dueOn 47 | ``` 48 | 49 | ### `id` 50 | 51 | ``` swift 52 | case id 53 | ``` 54 | 55 | ### `number` 56 | 57 | ``` swift 58 | case number 59 | ``` 60 | 61 | ### `openIssues` 62 | 63 | ``` swift 64 | case openIssues 65 | ``` 66 | 67 | ### `state` 68 | 69 | ``` swift 70 | case state 71 | ``` 72 | 73 | ### `title` 74 | 75 | ``` swift 76 | case title 77 | ``` 78 | 79 | ### `updatedAt` 80 | 81 | ``` swift 82 | case updatedAt 83 | ``` 84 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Milestone_State.md: -------------------------------------------------------------------------------- 1 | # GitHub.Milestone.State 2 | 3 | ``` swift 4 | public enum State 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `open` 14 | 15 | ``` swift 16 | case open 17 | ``` 18 | 19 | ### `closed` 20 | 21 | ``` swift 22 | case closed 23 | ``` 24 | 25 | ### `all` 26 | 27 | ``` swift 28 | case all 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_PullRequest_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitHub.PullRequest.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `number` 14 | 15 | ``` swift 16 | case number 17 | ``` 18 | 19 | ### `title` 20 | 21 | ``` swift 22 | case title 23 | ``` 24 | 25 | ### `body` 26 | 27 | ``` swift 28 | case body 29 | ``` 30 | 31 | ### `user` 32 | 33 | ``` swift 34 | case user 35 | ``` 36 | 37 | ### `assignee` 38 | 39 | ``` swift 40 | case assignee 41 | ``` 42 | 43 | ### `assignees` 44 | 45 | ``` swift 46 | case assignees 47 | ``` 48 | 49 | ### `milestone` 50 | 51 | ``` swift 52 | case milestone 53 | ``` 54 | 55 | ### `additions` 56 | 57 | ``` swift 58 | case additions 59 | ``` 60 | 61 | ### `deletions` 62 | 63 | ``` swift 64 | case deletions 65 | ``` 66 | 67 | ### `state` 68 | 69 | ``` swift 70 | case state 71 | ``` 72 | 73 | ### `head` 74 | 75 | ``` swift 76 | case head 77 | ``` 78 | 79 | ### `base` 80 | 81 | ``` swift 82 | case base 83 | ``` 84 | 85 | ### `isLocked` 86 | 87 | ``` swift 88 | case isLocked 89 | ``` 90 | 91 | ### `isMerged` 92 | 93 | ``` swift 94 | case isMerged 95 | ``` 96 | 97 | ### `createdAt` 98 | 99 | ``` swift 100 | case createdAt 101 | ``` 102 | 103 | ### `updatedAt` 104 | 105 | ``` swift 106 | case updatedAt 107 | ``` 108 | 109 | ### `closedAt` 110 | 111 | ``` swift 112 | case closedAt 113 | ``` 114 | 115 | ### `mergedAt` 116 | 117 | ``` swift 118 | case mergedAt 119 | ``` 120 | 121 | ### `commitCount` 122 | 123 | ``` swift 124 | case commitCount 125 | ``` 126 | 127 | ### `commentCount` 128 | 129 | ``` swift 130 | case commentCount 131 | ``` 132 | 133 | ### `reviewCommentCount` 134 | 135 | ``` swift 136 | case reviewCommentCount 137 | ``` 138 | 139 | ### `changedFiles` 140 | 141 | ``` swift 142 | case changedFiles 143 | ``` 144 | 145 | ### `htmlUrl` 146 | 147 | ``` swift 148 | case htmlUrl 149 | ``` 150 | 151 | ### `draft` 152 | 153 | ``` swift 154 | case draft 155 | ``` 156 | 157 | ### `links` 158 | 159 | ``` swift 160 | case links 161 | ``` 162 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_PullRequest_Link.md: -------------------------------------------------------------------------------- 1 | # GitHub.PullRequest.Link 2 | 3 | Pull Requests have possible link relations 4 | 5 | ``` swift 6 | struct Link:​ Decodable, Equatable 7 | ``` 8 | 9 | - See:​ 10 | [Reference](https:​//docs.github.com/en/rest/reference/pulls#link-relations) 11 | 12 | ## Inheritance 13 | 14 | `Decodable`, `Equatable` 15 | 16 | ## Properties 17 | 18 | ### `` `self` `` 19 | 20 | The API location of the Pull Request. 21 | 22 | ``` swift 23 | let `self`:​ Relation 24 | ``` 25 | 26 | ### `html` 27 | 28 | The HTML location of the Pull Request. 29 | 30 | ``` swift 31 | let html:​ Relation 32 | ``` 33 | 34 | ### `issue` 35 | 36 | The API location of the Pull Request's Issue. 37 | 38 | ``` swift 39 | let issue:​ Relation 40 | ``` 41 | 42 | ### `comments` 43 | 44 | The API location of the Pull Request's Issue comments. 45 | 46 | ``` swift 47 | let comments:​ Relation 48 | ``` 49 | 50 | ### `reviewComments` 51 | 52 | The API location of the Pull Request's Review comments. 53 | 54 | ``` swift 55 | let reviewComments:​ Relation 56 | ``` 57 | 58 | ### `reviewComment` 59 | 60 | The URL template to construct the API location for a Review comment in the Pull Request's repository. 61 | 62 | ``` swift 63 | let reviewComment:​ Relation 64 | ``` 65 | 66 | ### `commits` 67 | 68 | The API location of the Pull Request's commits. 69 | 70 | ``` swift 71 | let commits:​ Relation 72 | ``` 73 | 74 | ### `statuses` 75 | 76 | The API location of the Pull Request's commit statuses, which are the statuses of its head branch. 77 | 78 | ``` swift 79 | let statuses:​ Relation 80 | ``` 81 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_PullRequest_Link_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitHub.PullRequest.Link.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `` `self` `` 14 | 15 | ``` swift 16 | case `self` 17 | ``` 18 | 19 | ### `html` 20 | 21 | ``` swift 22 | case html 23 | ``` 24 | 25 | ### `issue` 26 | 27 | ``` swift 28 | case issue 29 | ``` 30 | 31 | ### `comments` 32 | 33 | ``` swift 34 | case comments 35 | ``` 36 | 37 | ### `reviewComments` 38 | 39 | ``` swift 40 | case reviewComments 41 | ``` 42 | 43 | ### `reviewComment` 44 | 45 | ``` swift 46 | case reviewComment 47 | ``` 48 | 49 | ### `commits` 50 | 51 | ``` swift 52 | case commits 53 | ``` 54 | 55 | ### `statuses` 56 | 57 | ``` swift 58 | case statuses 59 | ``` 60 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_PullRequest_Link_Relation.md: -------------------------------------------------------------------------------- 1 | # GitHub.PullRequest.Link.Relation 2 | 3 | ``` swift 4 | public struct Relation:​ Decodable, Equatable, ExpressibleByStringLiteral 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable`, `ExpressibleByStringLiteral` 10 | 11 | ## Initializers 12 | 13 | ### `init(stringLiteral:​)` 14 | 15 | ``` swift 16 | public init(stringLiteral value:​ String) 17 | ``` 18 | 19 | ## Properties 20 | 21 | ### `href` 22 | 23 | ``` swift 24 | let href:​ String 25 | ``` 26 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_PullRequest_PullRequestState.md: -------------------------------------------------------------------------------- 1 | # GitHub.PullRequest.PullRequestState 2 | 3 | ``` swift 4 | public enum PullRequestState 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `open` 14 | 15 | ``` swift 16 | case open 17 | ``` 18 | 19 | ### `closed` 20 | 21 | ``` swift 22 | case closed 23 | ``` 24 | 25 | ### `merged` 26 | 27 | ``` swift 28 | case merged 29 | ``` 30 | 31 | ### `locked` 32 | 33 | ``` swift 34 | case locked 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Repo.md: -------------------------------------------------------------------------------- 1 | # GitHub.Repo 2 | 3 | ``` swift 4 | struct Repo:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | Generic UUID. 16 | 17 | ``` swift 18 | let id:​ Int 19 | ``` 20 | 21 | ### `name` 22 | 23 | The name of the repo, e.g. "danger-swift". 24 | 25 | ``` swift 26 | let name:​ String 27 | ``` 28 | 29 | ### `fullName` 30 | 31 | The full name of the owner + repo, e.g. "Danger/danger-swift" 32 | 33 | ``` swift 34 | let fullName:​ String 35 | ``` 36 | 37 | ### `owner` 38 | 39 | The owner of the repo. 40 | 41 | ``` swift 42 | let owner:​ User 43 | ``` 44 | 45 | ### `isPrivate` 46 | 47 | A boolean stating whether the repo is publicly accessible. 48 | 49 | ``` swift 50 | let isPrivate:​ Bool 51 | ``` 52 | 53 | ### `description` 54 | 55 | A textual description of the repo. 56 | 57 | ``` swift 58 | let description:​ String? 59 | ``` 60 | 61 | ### `isFork` 62 | 63 | A boolean stating whether the repo is a fork. 64 | 65 | ``` swift 66 | let isFork:​ Bool 67 | ``` 68 | 69 | ### `htmlURL` 70 | 71 | The root web URL for the repo, e.g. https:​//github.com/artsy/emission 72 | 73 | ``` swift 74 | let htmlURL:​ String 75 | ``` 76 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Repo_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitHub.Repo.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `name` 20 | 21 | ``` swift 22 | case name 23 | ``` 24 | 25 | ### `owner` 26 | 27 | ``` swift 28 | case owner 29 | ``` 30 | 31 | ### `description` 32 | 33 | ``` swift 34 | case description 35 | ``` 36 | 37 | ### `fullName` 38 | 39 | ``` swift 40 | case fullName 41 | ``` 42 | 43 | ### `isPrivate` 44 | 45 | ``` swift 46 | case isPrivate 47 | ``` 48 | 49 | ### `isFork` 50 | 51 | ``` swift 52 | case isFork 53 | ``` 54 | 55 | ### `htmlURL` 56 | 57 | ``` swift 58 | case htmlURL 59 | ``` 60 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_RequestedReviewers.md: -------------------------------------------------------------------------------- 1 | # GitHub.RequestedReviewers 2 | 3 | Represents the payload for a PR's requested reviewers value. 4 | 5 | ``` swift 6 | struct RequestedReviewers:​ Decodable, Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `users` 16 | 17 | The list of users of whom a review has been requested. 18 | 19 | ``` swift 20 | let users:​ [User] 21 | ``` 22 | 23 | ### `teams` 24 | 25 | The list of teams of whom a review has been requested. 26 | 27 | ``` swift 28 | let teams:​ [Team] 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Review.md: -------------------------------------------------------------------------------- 1 | # GitHub.Review 2 | 3 | ``` swift 4 | struct Review:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `body` 14 | 15 | The body of the review (if a review was made). 16 | 17 | ``` swift 18 | let body:​ String? 19 | ``` 20 | 21 | ### `commitId` 22 | 23 | The commit ID the review was made on (if a review was made). 24 | 25 | ``` swift 26 | let commitId:​ String? 27 | ``` 28 | 29 | ### `id` 30 | 31 | The id for the review (if a review was made). 32 | 33 | ``` swift 34 | let id:​ Int? 35 | ``` 36 | 37 | ### `state` 38 | 39 | The state of the review (if a review was made). 40 | 41 | ``` swift 42 | let state:​ State? 43 | ``` 44 | 45 | ### `submittedAt` 46 | 47 | The date when the review was submitted 48 | 49 | ``` swift 50 | let submittedAt:​ Date 51 | ``` 52 | 53 | ### `user` 54 | 55 | The user who has completed the review or has been requested to review. 56 | 57 | ``` swift 58 | let user:​ User 59 | ``` 60 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Review_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitHub.Review.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `body` 14 | 15 | ``` swift 16 | case body 17 | ``` 18 | 19 | ### `commitId` 20 | 21 | ``` swift 22 | case commitId 23 | ``` 24 | 25 | ### `id` 26 | 27 | ``` swift 28 | case id 29 | ``` 30 | 31 | ### `state` 32 | 33 | ``` swift 34 | case state 35 | ``` 36 | 37 | ### `submittedAt` 38 | 39 | ``` swift 40 | case submittedAt 41 | ``` 42 | 43 | ### `user` 44 | 45 | ``` swift 46 | case user 47 | ``` 48 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Review_State.md: -------------------------------------------------------------------------------- 1 | # GitHub.Review.State 2 | 3 | ``` swift 4 | public enum State 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `approved` 14 | 15 | ``` swift 16 | case approved 17 | ``` 18 | 19 | ### `requestedChanges` 20 | 21 | ``` swift 22 | case requestedChanges 23 | ``` 24 | 25 | ### `comment` 26 | 27 | ``` swift 28 | case comment 29 | ``` 30 | 31 | ### `pending` 32 | 33 | ``` swift 34 | case pending 35 | ``` 36 | 37 | ### `dismissed` 38 | 39 | ``` swift 40 | case dismissed 41 | ``` 42 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_Team.md: -------------------------------------------------------------------------------- 1 | # GitHub.Team 2 | 3 | A GitHub team. 4 | 5 | ``` swift 6 | struct Team:​ Decodable, Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `id` 16 | 17 | The UUID for the team. 18 | 19 | ``` swift 20 | let id:​ Int 21 | ``` 22 | 23 | ### `name` 24 | 25 | The team name 26 | 27 | ``` swift 28 | let name:​ String 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_User.md: -------------------------------------------------------------------------------- 1 | # GitHub.User 2 | 3 | A GitHub user account. 4 | 5 | ``` swift 6 | struct User:​ Decodable, Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Decodable`, `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `id` 16 | 17 | The UUID for the user organization. 18 | 19 | ``` swift 20 | let id:​ Int 21 | ``` 22 | 23 | ### `login` 24 | 25 | The handle for the user or organization. 26 | 27 | ``` swift 28 | let login:​ String 29 | ``` 30 | 31 | ### `userType` 32 | 33 | The type of user:​ user, organization, or bot. 34 | 35 | ``` swift 36 | let userType:​ UserType 37 | ``` 38 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_User_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitHub.User.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `login` 20 | 21 | ``` swift 22 | case login 23 | ``` 24 | 25 | ### `userType` 26 | 27 | ``` swift 28 | case userType 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/GitHub_User_UserType.md: -------------------------------------------------------------------------------- 1 | # GitHub.User.UserType 2 | 3 | ``` swift 4 | public enum UserType 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `user` 14 | 15 | ``` swift 16 | case user 17 | ``` 18 | 19 | ### `organization` 20 | 21 | ``` swift 22 | case organization 23 | ``` 24 | 25 | ### `bot` 26 | 27 | ``` swift 28 | case bot 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab.md: -------------------------------------------------------------------------------- 1 | # GitLab 2 | 3 | ``` swift 4 | public struct GitLab:​ Decodable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable` 10 | 11 | ## Properties 12 | 13 | ### `mergeRequest` 14 | 15 | ``` swift 16 | let mergeRequest:​ MergeRequest 17 | ``` 18 | 19 | ### `metadata` 20 | 21 | ``` swift 22 | let metadata:​ Metadata 23 | ``` 24 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitLab.CodingKeys 2 | 3 | ``` swift 4 | public enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `mergeRequest` 14 | 15 | ``` swift 16 | case mergeRequest 17 | ``` 18 | 19 | ### `metadata` 20 | 21 | ``` swift 22 | case metadata 23 | ``` 24 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_DiffRefs.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.DiffRefs 2 | 3 | ``` swift 4 | public struct DiffRefs:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `baseSha` 14 | 15 | ``` swift 16 | let baseSha:​ String 17 | ``` 18 | 19 | ### `headSha` 20 | 21 | ``` swift 22 | let headSha:​ String 23 | ``` 24 | 25 | ### `startSha` 26 | 27 | ``` swift 28 | let startSha:​ String 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_DiffRefs_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.DiffRefs.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `baseSha` 14 | 15 | ``` swift 16 | case baseSha 17 | ``` 18 | 19 | ### `headSha` 20 | 21 | ``` swift 22 | case headSha 23 | ``` 24 | 25 | ### `startSha` 26 | 27 | ``` swift 28 | case startSha 29 | ``` 30 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_Milestone.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.Milestone 2 | 3 | ``` swift 4 | public struct Milestone:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Initializers 12 | 13 | ### `init(from:​)` 14 | 15 | ``` swift 16 | init(from decoder:​ Decoder) throws 17 | ``` 18 | 19 | ## Properties 20 | 21 | ### `createdAt` 22 | 23 | ``` swift 24 | let createdAt:​ Date 25 | ``` 26 | 27 | ### `description` 28 | 29 | ``` swift 30 | let description:​ String 31 | ``` 32 | 33 | ### `dueDate` 34 | 35 | ``` swift 36 | let dueDate:​ Date? 37 | ``` 38 | 39 | ### `id` 40 | 41 | ``` swift 42 | let id:​ Int 43 | ``` 44 | 45 | ### `iid` 46 | 47 | ``` swift 48 | let iid:​ Int 49 | ``` 50 | 51 | ### `parent` 52 | 53 | An unified identifier for [project milestone](https:​//docs.gitlab.com/ee/api/milestones.html)'s `project_id` 54 | and [group milestone](https:​//docs.gitlab.com/ee/api/group_milestones.html)'s `group_id`. 55 | 56 | ``` swift 57 | let parent:​ ParentIdentifier 58 | ``` 59 | 60 | ### `startDate` 61 | 62 | ``` swift 63 | let startDate:​ Date? 64 | ``` 65 | 66 | ### `state` 67 | 68 | ``` swift 69 | let state:​ State 70 | ``` 71 | 72 | ### `title` 73 | 74 | ``` swift 75 | let title:​ String 76 | ``` 77 | 78 | ### `updatedAt` 79 | 80 | ``` swift 81 | let updatedAt:​ Date 82 | ``` 83 | 84 | ### `webUrl` 85 | 86 | ``` swift 87 | let webUrl:​ String 88 | ``` 89 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_Milestone_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.Milestone.CodingKeys 2 | 3 | ``` swift 4 | public enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `createdAt` 14 | 15 | ``` swift 16 | case createdAt 17 | ``` 18 | 19 | ### `description` 20 | 21 | ``` swift 22 | case description 23 | ``` 24 | 25 | ### `dueDate` 26 | 27 | ``` swift 28 | case dueDate 29 | ``` 30 | 31 | ### `id` 32 | 33 | ``` swift 34 | case id 35 | ``` 36 | 37 | ### `iid` 38 | 39 | ``` swift 40 | case iid 41 | ``` 42 | 43 | ### `projectId` 44 | 45 | ``` swift 46 | case projectId 47 | ``` 48 | 49 | ### `groupId` 50 | 51 | ``` swift 52 | case groupId 53 | ``` 54 | 55 | ### `startDate` 56 | 57 | ``` swift 58 | case startDate 59 | ``` 60 | 61 | ### `state` 62 | 63 | ``` swift 64 | case state 65 | ``` 66 | 67 | ### `title` 68 | 69 | ``` swift 70 | case title 71 | ``` 72 | 73 | ### `updatedAt` 74 | 75 | ``` swift 76 | case updatedAt 77 | ``` 78 | 79 | ### `webUrl` 80 | 81 | ``` swift 82 | case webUrl 83 | ``` 84 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_Milestone_ParentIdentifier.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.Milestone.ParentIdentifier 2 | 3 | ``` swift 4 | public enum ParentIdentifier 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Equatable` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `group` 14 | 15 | ``` swift 16 | case group(:​ Int) 17 | ``` 18 | 19 | ### `project` 20 | 21 | ``` swift 22 | case project(:​ Int) 23 | ``` 24 | 25 | ## Properties 26 | 27 | ### `id` 28 | 29 | ``` swift 30 | var id:​ Int 31 | ``` 32 | 33 | ### `isGroup` 34 | 35 | ``` swift 36 | var isGroup:​ Bool 37 | ``` 38 | 39 | ### `isProject` 40 | 41 | ``` swift 42 | var isProject:​ Bool 43 | ``` 44 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_Milestone_ParentIdentifier_Error.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.Milestone.ParentIdentifier.Error 2 | 3 | ``` swift 4 | enum Error 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `LocalizedError` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `validKeyNotFound` 14 | 15 | ``` swift 16 | case validKeyNotFound 17 | ``` 18 | 19 | ## Properties 20 | 21 | ### `errorDescription` 22 | 23 | ``` swift 24 | var errorDescription:​ String? 25 | ``` 26 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_Milestone_State.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.Milestone.State 2 | 3 | ``` swift 4 | public enum State 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `active` 14 | 15 | ``` swift 16 | case active 17 | ``` 18 | 19 | ### `closed` 20 | 21 | ``` swift 22 | case closed 23 | ``` 24 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_Pipeline.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.Pipeline 2 | 3 | ``` swift 4 | public struct Pipeline:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | let id:​ Int 17 | ``` 18 | 19 | ### `ref` 20 | 21 | ``` swift 22 | let ref:​ String 23 | ``` 24 | 25 | ### `sha` 26 | 27 | ``` swift 28 | let sha:​ String 29 | ``` 30 | 31 | ### `status` 32 | 33 | ``` swift 34 | let status:​ Status 35 | ``` 36 | 37 | ### `webUrl` 38 | 39 | ``` swift 40 | let webUrl:​ String 41 | ``` 42 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_Pipeline_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.Pipeline.CodingKeys 2 | 3 | ``` swift 4 | public enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `id` 14 | 15 | ``` swift 16 | case id 17 | ``` 18 | 19 | ### `ref` 20 | 21 | ``` swift 22 | case ref 23 | ``` 24 | 25 | ### `sha` 26 | 27 | ``` swift 28 | case sha 29 | ``` 30 | 31 | ### `status` 32 | 33 | ``` swift 34 | case status 35 | ``` 36 | 37 | ### `webUrl` 38 | 39 | ``` swift 40 | case webUrl 41 | ``` 42 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_Pipeline_Status.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.Pipeline.Status 2 | 3 | ``` swift 4 | public enum Status 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `canceled` 14 | 15 | ``` swift 16 | case canceled 17 | ``` 18 | 19 | ### `failed` 20 | 21 | ``` swift 22 | case failed 23 | ``` 24 | 25 | ### `pending` 26 | 27 | ``` swift 28 | case pending 29 | ``` 30 | 31 | ### `running` 32 | 33 | ``` swift 34 | case running 35 | ``` 36 | 37 | ### `skipped` 38 | 39 | ``` swift 40 | case skipped 41 | ``` 42 | 43 | ### `success` 44 | 45 | ``` swift 46 | case success 47 | ``` 48 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_State.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.State 2 | 3 | ``` swift 4 | public enum State 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `closed` 14 | 15 | ``` swift 16 | case closed 17 | ``` 18 | 19 | ### `locked` 20 | 21 | ``` swift 22 | case locked 23 | ``` 24 | 25 | ### `merged` 26 | 27 | ``` swift 28 | case merged 29 | ``` 30 | 31 | ### `opened` 32 | 33 | ``` swift 34 | case opened 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_TimeStats.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.TimeStats 2 | 3 | ``` swift 4 | public struct TimeStats:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `humanTimeEstimate` 14 | 15 | ``` swift 16 | let humanTimeEstimate:​ Int? 17 | ``` 18 | 19 | ### `humanTimeSpent` 20 | 21 | ``` swift 22 | let humanTimeSpent:​ Int? 23 | ``` 24 | 25 | ### `timeEstimate` 26 | 27 | ``` swift 28 | let timeEstimate:​ Int 29 | ``` 30 | 31 | ### `totalTimeSpent` 32 | 33 | ``` swift 34 | let totalTimeSpent:​ Int 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_TimeStats_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.TimeStats.CodingKeys 2 | 3 | ``` swift 4 | public enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `humanTimeEstimate` 14 | 15 | ``` swift 16 | case humanTimeEstimate 17 | ``` 18 | 19 | ### `humanTimeSpent` 20 | 21 | ``` swift 22 | case humanTimeSpent 23 | ``` 24 | 25 | ### `timeEstimate` 26 | 27 | ``` swift 28 | case timeEstimate 29 | ``` 30 | 31 | ### `totalTimeSpent` 32 | 33 | ``` swift 34 | case totalTimeSpent 35 | ``` 36 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_UserMergeData.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.UserMergeData 2 | 3 | ``` swift 4 | struct UserMergeData:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `canMerge` 14 | 15 | ``` swift 16 | let canMerge:​ Bool 17 | ``` 18 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_MergeRequest_UserMergeData_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitLab.MergeRequest.UserMergeData.CodingKeys 2 | 3 | ``` swift 4 | enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `canMerge` 14 | 15 | ``` swift 16 | case canMerge 17 | ``` 18 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_Metadata.md: -------------------------------------------------------------------------------- 1 | # GitLab.Metadata 2 | 3 | ``` swift 4 | struct Metadata:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `pullRequestID` 14 | 15 | ``` swift 16 | let pullRequestID:​ String 17 | ``` 18 | 19 | ### `repoSlug` 20 | 21 | ``` swift 22 | let repoSlug:​ String 23 | ``` 24 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_User.md: -------------------------------------------------------------------------------- 1 | # GitLab.User 2 | 3 | ``` swift 4 | struct User:​ Decodable, Equatable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `Equatable` 10 | 11 | ## Properties 12 | 13 | ### `avatarUrl` 14 | 15 | ``` swift 16 | let avatarUrl:​ String? 17 | ``` 18 | 19 | ### `id` 20 | 21 | ``` swift 22 | let id:​ Int 23 | ``` 24 | 25 | ### `name` 26 | 27 | ``` swift 28 | let name:​ String 29 | ``` 30 | 31 | ### `state` 32 | 33 | ``` swift 34 | let state:​ State 35 | ``` 36 | 37 | ### `username` 38 | 39 | ``` swift 40 | let username:​ String 41 | ``` 42 | 43 | ### `webUrl` 44 | 45 | ``` swift 46 | let webUrl:​ String 47 | ``` 48 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_User_CodingKeys.md: -------------------------------------------------------------------------------- 1 | # GitLab.User.CodingKeys 2 | 3 | ``` swift 4 | public enum CodingKeys 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `CodingKey`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `avatarUrl` 14 | 15 | ``` swift 16 | case avatarUrl 17 | ``` 18 | 19 | ### `id` 20 | 21 | ``` swift 22 | case id 23 | ``` 24 | 25 | ### `name` 26 | 27 | ``` swift 28 | case name 29 | ``` 30 | 31 | ### `state` 32 | 33 | ``` swift 34 | case state 35 | ``` 36 | 37 | ### `username` 38 | 39 | ``` swift 40 | case username 41 | ``` 42 | 43 | ### `webUrl` 44 | 45 | ``` swift 46 | case webUrl 47 | ``` 48 | -------------------------------------------------------------------------------- /Documentation/reference/GitLab_User_State.md: -------------------------------------------------------------------------------- 1 | # GitLab.User.State 2 | 3 | ``` swift 4 | public enum State 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `active` 14 | 15 | ``` swift 16 | case active 17 | ``` 18 | 19 | ### `blocked` 20 | 21 | ``` swift 22 | case blocked 23 | ``` 24 | -------------------------------------------------------------------------------- /Documentation/reference/Git_Commit.md: -------------------------------------------------------------------------------- 1 | # Git.Commit 2 | 3 | A platform agnostic reference to a git commit. 4 | 5 | ``` swift 6 | struct Commit:​ Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `sha` 16 | 17 | The SHA for the commit. 18 | 19 | ``` swift 20 | let sha:​ String? 21 | ``` 22 | 23 | ### `author` 24 | 25 | Who wrote the commit. 26 | 27 | ``` swift 28 | let author:​ Author 29 | ``` 30 | 31 | ### `committer` 32 | 33 | Who shipped the code. 34 | 35 | ``` swift 36 | let committer:​ Author 37 | ``` 38 | 39 | ### `message` 40 | 41 | The message for the commit. 42 | 43 | ``` swift 44 | let message:​ String 45 | ``` 46 | 47 | ### `parents` 48 | 49 | SHAs for the commit's parents. 50 | 51 | ``` swift 52 | let parents:​ [String]? 53 | ``` 54 | 55 | ### `url` 56 | 57 | The URL for the commit. 58 | 59 | ``` swift 60 | let url:​ String? 61 | ``` 62 | -------------------------------------------------------------------------------- /Documentation/reference/Git_Commit_Author.md: -------------------------------------------------------------------------------- 1 | # Git.Commit.Author 2 | 3 | The author of a commit. 4 | 5 | ``` swift 6 | public struct Author:​ Equatable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Equatable` 12 | 13 | ## Properties 14 | 15 | ### `name` 16 | 17 | The display name for the author. 18 | 19 | ``` swift 20 | let name:​ String 21 | ``` 22 | 23 | ### `email` 24 | 25 | The email for the author. 26 | 27 | ``` swift 28 | let email:​ String 29 | ``` 30 | 31 | ### `date` 32 | 33 | The ISO8601 date string for the commit. 34 | 35 | ``` swift 36 | let date:​ String 37 | ``` 38 | -------------------------------------------------------------------------------- /Documentation/reference/Meta.md: -------------------------------------------------------------------------------- 1 | # Meta 2 | 3 | Meta information for showing in the text info 4 | 5 | ``` swift 6 | public struct Meta:​ Encodable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Encodable` 12 | -------------------------------------------------------------------------------- /Documentation/reference/Optional.md: -------------------------------------------------------------------------------- 1 | # Extensions on Optional 2 | 3 | ## Methods 4 | 5 | ### `getString(default:)` 6 | 7 | ``` swift 8 | public func getString(default defaultString: String) -> String 9 | ``` 10 | 11 | ### `getBoolean(default:)` 12 | 13 | ``` swift 14 | public func getBoolean(default defaultBoolean: Bool) -> Bool 15 | ``` 16 | -------------------------------------------------------------------------------- /Documentation/reference/SwiftLint.md: -------------------------------------------------------------------------------- 1 | # SwiftLint 2 | 3 | The SwiftLint plugin has been embedded inside Danger, making 4 | it usable out of the box. 5 | 6 | ``` swift 7 | public enum SwiftLint 8 | ``` 9 | 10 | ## Methods 11 | 12 | ### `lint(inline:​directory:​configFile:​strict:​quiet:​lintAllFiles:​swiftlintPath:​)` 13 | 14 | This method is deprecated in favor of 15 | 16 | ``` swift 17 | @available(*, deprecated, message:​ "Use the lint(_ lintStyle ..) method instead.") @discardableResult public static func lint(inline:​ Bool = false, directory:​ String? = nil, configFile:​ String? = nil, strict:​ Bool = false, quiet:​ Bool = true, lintAllFiles:​ Bool = false, swiftlintPath:​ String? = nil) -> [SwiftLintViolation] 18 | ``` 19 | 20 | ### `lint(_:​inline:​configFile:​strict:​quiet:​swiftlintPath:​)` 21 | 22 | When the swiftlintPath is not specified, 23 | it uses by default swift run swiftlint if the Package.swift in your root folder contains swiftlint as dependency, 24 | otherwise calls directly the swiftlint command 25 | 26 | ``` swift 27 | @discardableResult @available(*, deprecated, message:​ "Use the lint(_ lintStyle ..) method instead.") public static func lint(_ lintStyle:​ LintStyle = .modifiedAndCreatedFiles(directory:​ nil), inline:​ Bool = false, configFile:​ String? = nil, strict:​ Bool = false, quiet:​ Bool = true, swiftlintPath:​ String?) -> [SwiftLintViolation] 28 | ``` 29 | 30 | ### `lint(_:​inline:​configFile:​strict:​quiet:​swiftlintPath:​)` 31 | 32 | This is the main entry point for linting Swift in PRs. 33 | 34 | ``` swift 35 | @discardableResult public static func lint(_ lintStyle:​ LintStyle = .modifiedAndCreatedFiles(directory:​ nil), inline:​ Bool = false, configFile:​ String? = nil, strict:​ Bool = false, quiet:​ Bool = true, swiftlintPath:​ SwiftlintPath? = nil) -> [SwiftLintViolation] 36 | ``` 37 | 38 | When the swiftlintPath is not specified, 39 | it uses by default swift run swiftlint if the Package.swift in your root folder contains swiftlint as dependency, 40 | otherwise calls directly the swiftlint command 41 | -------------------------------------------------------------------------------- /Documentation/reference/SwiftLintViolation.md: -------------------------------------------------------------------------------- 1 | # SwiftLintViolation 2 | 3 | ``` swift 4 | public struct SwiftLintViolation:​ Decodable 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable` 10 | 11 | ## Properties 12 | 13 | ### `ruleID` 14 | 15 | ``` swift 16 | var ruleID:​ String 17 | ``` 18 | 19 | ### `reason` 20 | 21 | ``` swift 22 | var reason:​ String 23 | ``` 24 | 25 | ### `line` 26 | 27 | ``` swift 28 | var line:​ Int 29 | ``` 30 | 31 | ### `severity` 32 | 33 | ``` swift 34 | var severity:​ Severity 35 | ``` 36 | 37 | ### `file` 38 | 39 | ``` swift 40 | var file:​ String 41 | ``` 42 | 43 | ## Methods 44 | 45 | ### `toMarkdown()` 46 | 47 | ``` swift 48 | public func toMarkdown() -> String 49 | ``` 50 | -------------------------------------------------------------------------------- /Documentation/reference/SwiftLintViolation_Severity.md: -------------------------------------------------------------------------------- 1 | # SwiftLintViolation.Severity 2 | 3 | ``` swift 4 | public enum Severity 5 | ``` 6 | 7 | ## Inheritance 8 | 9 | `Decodable`, `String` 10 | 11 | ## Enumeration Cases 12 | 13 | ### `warning` 14 | 15 | ``` swift 16 | case warning 17 | ``` 18 | 19 | ### `error` 20 | 21 | ``` swift 22 | case error 23 | ``` 24 | -------------------------------------------------------------------------------- /Documentation/reference/SwiftLint_LintStyle.md: -------------------------------------------------------------------------------- 1 | # SwiftLint.LintStyle 2 | 3 | ``` swift 4 | public enum LintStyle 5 | ``` 6 | 7 | ## Enumeration Cases 8 | 9 | ### `all` 10 | 11 | Lints all the files instead of only the modified and created files. 12 | 13 | ``` swift 14 | case all(directory:​ String?) 15 | ``` 16 | 17 | #### Parameters 18 | 19 | - directory:​ - directory:​ Optional property to set the --path to execute at. 20 | 21 | ### `modifiedAndCreatedFiles` 22 | 23 | Only lints the modified and created files with `.swift` extension. 24 | 25 | ``` swift 26 | case modifiedAndCreatedFiles(directory:​ String?) 27 | ``` 28 | 29 | #### Parameters 30 | 31 | - directory:​ - directory:​ Optional property to set the --path to execute at. 32 | 33 | ### `files` 34 | 35 | Lints only the given files. This can be useful to do some manual filtering. 36 | The files will be filtered on `.swift` only. 37 | 38 | ``` swift 39 | case files(:​ [File]) 40 | ``` 41 | -------------------------------------------------------------------------------- /Documentation/reference/SwiftLint_SwiftlintPath.md: -------------------------------------------------------------------------------- 1 | # SwiftLint.SwiftlintPath 2 | 3 | ``` swift 4 | public enum SwiftlintPath 5 | ``` 6 | 7 | ## Enumeration Cases 8 | 9 | ### `swiftPackage` 10 | 11 | ``` swift 12 | case swiftPackage(:​ String) 13 | ``` 14 | 15 | ### `bin` 16 | 17 | ``` swift 18 | case bin(:​ String) 19 | ``` 20 | -------------------------------------------------------------------------------- /Documentation/reference/Violation.md: -------------------------------------------------------------------------------- 1 | # Violation 2 | 3 | The result of a warn, message, or fail. 4 | 5 | ``` swift 6 | public struct Violation:​ Encodable 7 | ``` 8 | 9 | ## Inheritance 10 | 11 | `Encodable` 12 | -------------------------------------------------------------------------------- /Documentation/reference/_Footer.md: -------------------------------------------------------------------------------- 1 | Generated at 2021-08-04T13:​56:​08+0200 using [swift-doc](https:​//github.com/SwiftDocOrg/swift-doc) 1.0.0-beta.3. 2 | -------------------------------------------------------------------------------- /Documentation/reference/fail(_:).md: -------------------------------------------------------------------------------- 1 | # fail(\_:​) 2 | 3 | Adds a warning message to the Danger report 4 | 5 | ``` swift 6 | public func fail(_ message:​ String) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | - message:​ - message:​ A markdown-ish 12 | -------------------------------------------------------------------------------- /Documentation/reference/fail(message:file:line:).md: -------------------------------------------------------------------------------- 1 | # fail(message:​file:​line:​) 2 | 3 | Adds an inline fail message to the Danger report 4 | 5 | ``` swift 6 | public func fail(message:​ String, file:​ String, line:​ Int) 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/fails.md: -------------------------------------------------------------------------------- 1 | # fails 2 | 3 | Fails on the Danger report 4 | 5 | ``` swift 6 | var fails:​ [Violation] 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/markdown(_:).md: -------------------------------------------------------------------------------- 1 | # markdown(\_:​) 2 | 3 | Adds a warning message to the Danger report 4 | 5 | ``` swift 6 | public func markdown(_ message:​ String) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | - message:​ - message:​ A markdown-ish 12 | -------------------------------------------------------------------------------- /Documentation/reference/markdown(message:file:line:).md: -------------------------------------------------------------------------------- 1 | # markdown(message:​file:​line:​) 2 | 3 | Adds an inline message to the Danger report 4 | 5 | ``` swift 6 | public func markdown(message:​ String, file:​ String, line:​ Int) 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/markdowns.md: -------------------------------------------------------------------------------- 1 | # markdowns 2 | 3 | Markdowns on the Danger report 4 | 5 | ``` swift 6 | var markdowns:​ [Violation] 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/message(_:).md: -------------------------------------------------------------------------------- 1 | # message(\_:​) 2 | 3 | Adds a warning message to the Danger report 4 | 5 | ``` swift 6 | public func message(_ message:​ String) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | - message:​ - message:​ A markdown-ish 12 | -------------------------------------------------------------------------------- /Documentation/reference/message(message:file:line:).md: -------------------------------------------------------------------------------- 1 | # message(message:​file:​line:​) 2 | 3 | Adds an inline message to the Danger report 4 | 5 | ``` swift 6 | public func message(message:​ String, file:​ String, line:​ Int) 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/messages.md: -------------------------------------------------------------------------------- 1 | # messages 2 | 3 | Messages on the Danger report 4 | 5 | ``` swift 6 | var messages:​ [Violation] 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/suggestion(code:file:line:).md: -------------------------------------------------------------------------------- 1 | # suggestion(code:​file:​line:​) 2 | 3 | Adds an inline suggestion to the Danger report (sends a normal message if suggestions are not supported) 4 | 5 | ``` swift 6 | public func suggestion(code:​ String, file:​ String, line:​ Int) 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/warn(_:).md: -------------------------------------------------------------------------------- 1 | # warn(\_:​) 2 | 3 | Adds a warning message to the Danger report 4 | 5 | ``` swift 6 | public func warn(_ message:​ String) 7 | ``` 8 | 9 | ## Parameters 10 | 11 | - message:​ - message:​ A markdown-ish 12 | -------------------------------------------------------------------------------- /Documentation/reference/warn(message:file:line:).md: -------------------------------------------------------------------------------- 1 | # warn(message:​file:​line:​) 2 | 3 | Adds an inline warning message to the Danger report 4 | 5 | ``` swift 6 | public func warn(message:​ String, file:​ String, line:​ Int) 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/reference/warnings.md: -------------------------------------------------------------------------------- 1 | # warnings 2 | 3 | Warnings on the Danger report 4 | 5 | ``` swift 6 | var warnings:​ [Violation] 7 | ``` 8 | -------------------------------------------------------------------------------- /Documentation/tutorials/images/swift-edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danger/swift/a2275ddf9e3b154f0cf96a72bc8fdb9040b7e4d8/Documentation/tutorials/images/swift-edit.png -------------------------------------------------------------------------------- /Documentation/usage/bitbucket_cloud.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Danger + BitBucket Cloud 3 | subtitle: Dangerous bits 4 | layout: guide_sw 5 | order: 4 6 | blurb: An overview of using Danger with BitBucket Cloud, and some examples 7 | --- 8 | 9 | To use Danger Swift with BitBucket Cloud: you'll need to create a new account for Danger to use, then set the following 10 | environment variables on your CI: 11 | 12 | You could use either username with password or OAuth key with OAuth secret. 13 | 14 | For username and password, you need to set. 15 | 16 | - `DANGER_BITBUCKETCLOUD_USERNAME` = The username for the account used to comment, as shown on 17 | https://bitbucket.org/account/ 18 | - `DANGER_BITBUCKETCLOUD_PASSWORD` = The password for the account used to comment, you could use 19 | [App passwords](https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html#Apppasswords-Aboutapppasswords) 20 | with Read Pull Requests and Read Account Permissions. 21 | 22 | For OAuth key and OAuth secret, you can get them from. 23 | 24 | - Open [BitBucket Cloud Website](https://bitbucket.org) 25 | - Navigate to Settings > OAuth > Add consumer 26 | - Put `https://bitbucket.org/site/oauth2/authorize` for `Callback URL`, and enable Read Pull requests, and Read Account 27 | Permission. 28 | 29 | - `DANGER_BITBUCKETCLOUD_OAUTH_KEY` = The consumer key for the account used to comment, as show as `Key` on the website. 30 | - `DANGER_BITBUCKETCLOUD_OAUTH_SECRET` = The consumer secret for the account used to comment, as show as `Secret` on the 31 | website. 32 | 33 | Then in your Dangerfiles you will have a fully fleshed out `danger.bitbucketCloud` object to work with. For example: 34 | 35 | ```ts 36 | if danger.bitbucketCloud.pr.title.contains("WIP") { 37 | warn("PR is considered WIP") 38 | } 39 | ``` 40 | 41 | The DSL is expansive, you can see all the details inside the [Danger Swift Reference][ref], but the TLDR is: 42 | 43 | ```ts 44 | danger.bitbucketCloud 45 | 46 | /** The pull request and repository metadata */ 47 | metadata: RepoMetaData 48 | /** The PR metadata */ 49 | pr: BitBucketCloudPRDSL 50 | /** The commits associated with the pull request */ 51 | commits: [BitBucketCloudCommit] 52 | /** The comments on the pull request */ 53 | comments: [BitBucketCloudPRComment] 54 | /** The activities such as OPENING, COMMENTING, CLOSING, MERGING or UPDATING a pull request */ 55 | activities: [BitBucketCloudPRActivity] 56 | ``` 57 | -------------------------------------------------------------------------------- /Documentation/usage/gitlab.html.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Danger + GitLab 3 | subtitle: Self-Hosted 4 | layout: guide_sw 5 | order: 5 6 | blurb: An overview of using Danger with GitLab, and some examples 7 | --- 8 | 9 | To use Danger Swift with GitLab: you'll need to create a new account for Danger to use, then set the following environment 10 | variables on your CI system: 11 | 12 | - `DANGER_GITLAB_HOST` = Defaults to `https://gitlab.com` but you can use it for your own url 13 | - `DANGER_GITLAB_API_TOKEN` = An access token for the account which will post comments 14 | 15 | Then in your Dangerfiles you will have a fully fleshed out `danger.gitlab` object to work with. For example: 16 | 17 | ```swift 18 | if (danger.gitLab.mergeRequest.title.contains("WIP")) { 19 | warn("MR is considered WIP") 20 | } 21 | ``` 22 | 23 | The DSL is expansive, you can see all the details inside the [Danger Swift Reference][ref], but the TLDR is: 24 | 25 | ```swift 26 | danger.gitLab. 27 | 28 | /** The pull request and repository metadata */ 29 | metadata: RepoMetaData 30 | /** The Merge Request metadata */ 31 | mergeRequest: GitLabMR 32 | ``` 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017-2022 Danger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TOOL_NAME = danger-swift 2 | # Get this from the Danger.swift someday 3 | 4 | PREFIX = /usr/local 5 | INSTALL_PATH = $(PREFIX)/bin/$(TOOL_NAME) 6 | 7 | docs: 8 | swift run swift-doc generate Sources/Danger --module-name Danger --output Documentation/reference 9 | ./Scripts/update_docs.rb 10 | 11 | version: 12 | Scripts/update_makefile.sh 13 | Scripts/update_danger_version.sh 14 | Scripts/update_changelog.sh 15 | 16 | deploy_tap: 17 | Scripts/create_homebrew_tap.sh 18 | 19 | install: 20 | Scripts/install.sh 21 | 22 | 23 | uninstall: 24 | rm -f $(INSTALL_PATH) 25 | -------------------------------------------------------------------------------- /Scripts/change_is_develop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | IS_DEVELOP=$1 4 | 5 | sed "s/let isDevelop = .*/let isDevelop = $IS_DEVELOP/" Package.swift > tmpPackage.swift 6 | mv -f tmpPackage.swift Package.swift -------------------------------------------------------------------------------- /Scripts/create_homebrew_tap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Clone tap repo 3 | 4 | GIT_ORIGIN_NAME=`git remote get-url origin` 5 | if [[ $GIT_ORIGIN_NAME != *"danger/"* ]]; then 6 | echo "Not creating homebrew tap because the git remote 'origin' is not in the danger organisation" 7 | exit 8 | fi 9 | 10 | TOOL_NAME=danger-swift 11 | 12 | HOMEBREW_TAP_TMPDIR=$(mktemp -d) 13 | git clone --depth 1 https://github.com/danger/homebrew-tap.git "$HOMEBREW_TAP_TMPDIR" 14 | cd "$HOMEBREW_TAP_TMPDIR" || exit 1 15 | 16 | TAR_FILENAME="$TOOL_NAME-$VERSION.tar.gz" 17 | wget "https://github.com/danger/$TOOL_NAME/archive/$VERSION.tar.gz" -O "$TAR_FILENAME" 2> /dev/null 18 | SHA=`shasum -a 256 "$TAR_FILENAME" | head -n1 | cut -d " " -f1` 19 | rm "$TAR_FILENAME" 2> /dev/null 20 | 21 | # git config user.name danger 22 | # git config user.email danger@users.noreply.github.com 23 | 24 | # Write formula 25 | echo "class DangerSwift < Formula" > danger-swift.rb 26 | echo " desc \"Write your Dangerfiles in Swift\"" >> danger-swift.rb 27 | echo " homepage \"https://github.com/danger/danger-swift\"" >> danger-swift.rb 28 | echo " version \"$VERSION\"" >> danger-swift.rb 29 | echo " url \"https://github.com/danger/danger-swift/archive/#{version}.tar.gz\"" >> danger-swift.rb 30 | echo " sha256 \"${SHA}\"" >> danger-swift.rb 31 | echo " head \"https://github.com/danger/danger-swift.git\"" >> danger-swift.rb 32 | echo >> danger-swift.rb 33 | echo " # Runs only on Xcode 14" >> danger-swift.rb 34 | echo " depends_on :xcode => [\"14\", :build]" >> danger-swift.rb 35 | echo " # Use the vendored danger" >> danger-swift.rb 36 | echo " depends_on \"danger/tap/danger-js\"" >> danger-swift.rb 37 | echo >> danger-swift.rb 38 | echo " def install" >> danger-swift.rb 39 | echo " system \"make\", \"install\", \"PREFIX=#{prefix}\"" >> danger-swift.rb 40 | echo " end" >> danger-swift.rb 41 | echo "end" >> danger-swift.rb 42 | 43 | #Commit changes 44 | git add danger-swift.rb 2> /dev/null 45 | git commit -m "Releasing danger-swift version $VERSION" --quiet 46 | git push origin master 47 | -------------------------------------------------------------------------------- /Scripts/data/request.template.yml: -------------------------------------------------------------------------------- 1 | # This file is a template for a command sent to SourceKitten which is used in the 2 | # generation of a module interface 3 | key.request: source.request.editor.open.interface 4 | key.name: "F6DA8E2C-95B6-40FB-ABC3-FE66F519B552" 5 | key.compilerargs: 6 | - "-target" 7 | - "x86_64-apple-macosx10.10" 8 | - "-module-name" 9 | - "danger-swift-Package" 10 | - "-sdk" 11 | - "[SDK_ROOT]" 12 | - "-I" 13 | - "-Xcc" 14 | - "[SDK_ROOT]/usr/local/include" 15 | - "-F" 16 | - "-Xcc" 17 | - "-F" 18 | - "[DEBUG_ROOT]" 19 | - "-F" 20 | - "-Xcc" 21 | - "-F" 22 | - "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks" 23 | - "-F" 24 | - "[SDK_ROOT]/System/Library/PrivateFrameworks" 25 | - "-D" 26 | - "SWIFT_PACKAGE" 27 | - "-D" 28 | - "DEBUG" 29 | - "-D" 30 | - "Xcode" 31 | - "-D" 32 | - "DEBUG=1" 33 | - "-Xcc" 34 | - "-I" 35 | - "-Xcc" 36 | - "[DEBUG_ROOT]" 37 | - "-Xcc" 38 | - "-I" 39 | - "-Xcc" 40 | - "[TMP_DIR]/danger-swift.build/Debug/DangerTests.build/swift-overrides.hmap" 41 | - "-Xcc" 42 | - "-I" 43 | - "-Xcc" 44 | - "[DEBUG_ROOT]/include" 45 | - "-Xcc" 46 | - "-I" 47 | - "-Xcc" 48 | - "[TMP_DIR]/danger-swift.build/Debug/DangerTests.build/DerivedSources/x86_64" 49 | - "-Xcc" 50 | - "-I" 51 | - "-Xcc" 52 | - "[TMP_DIR]/danger-swift.build/Debug/DangerTests.build/DerivedSources" 53 | - "-Xcc" 54 | - "-F" 55 | - "-Xcc" 56 | - "[DEBUG_ROOT]" 57 | - "-Xcc" 58 | - "-F" 59 | - "-Xcc" 60 | - "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks" 61 | - "-Xcc" 62 | - "-D" 63 | - "-Xcc" 64 | - "DEBUG=1" 65 | - "-Xcc" 66 | - "-working-directory" 67 | - "-Xcc" 68 | - "[CWD]" 69 | key.modulename: "Danger" 70 | key.toolchains: 71 | - "com.apple.dt.toolchain.XcodeDefault" 72 | key.synthesizedextensions: 1 -------------------------------------------------------------------------------- /Scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TOOL_NAME="danger-swift" 4 | PREFIX=${PREFIX:='/usr/local'} 5 | INSTALL_PATH="$PREFIX/bin/$TOOL_NAME" 6 | LIB_INSTALL_PATH="$PREFIX/lib/danger" 7 | declare -a SWIFT_LIB_FILES=('libDanger.dylib' 'libDanger.so' 'Danger.swiftdoc' 'Danger.swiftmodule' 'OctoKit.swiftdoc' 'OctoKit.swiftmodule' 'RequestKit.swiftdoc' 'RequestKit.swiftmodule' 'Logger.swiftdoc' 'Logger.swiftmodule' 'DangerShellExecutor.swiftdoc' 'DangerShellExecutor.swiftmodule') 8 | 9 | DANGER_LIB_DECLARATION='\.library(name:\ \"Danger\", targets: \[\"Danger\"\])' 10 | DANGER_LIB_DYNAMIC_DECLARATION='\.library(name:\ \"Danger\",\ type:\ \.dynamic,\ targets:\ \[\"Danger\"\])' 11 | sed "s/$DANGER_LIB_DECLARATION/$DANGER_LIB_DYNAMIC_DECLARATION/g" Package.swift > tmpPackage 12 | mv -f tmpPackage Package.swift 13 | 14 | swift package clean 15 | 16 | if [[ "$OSTYPE" == "darwin"* ]]; then 17 | BUILD_FOLDER=".build/release" 18 | swift build --disable-sandbox -c release 19 | MAJOR_VERSION=$(swift --version | awk '{print $4}' | cut -d '.' -f 1) 20 | else 21 | BUILD_FOLDER=".build/debug" 22 | swift build --disable-sandbox 23 | MAJOR_VERSION=$(swift --version | awk '{for(i=1;i<=NF;i++){if($i ~ /^[0-9]+\.[0-9]+(\.[0-9]+)?$/){print $i; break}}}' | cut -d '.' -f 1) 24 | fi 25 | 26 | mkdir -p "$PREFIX/bin" 27 | mkdir -p "$LIB_INSTALL_PATH" 28 | cp -f "$BUILD_FOLDER/$TOOL_NAME" "$INSTALL_PATH" 29 | 30 | ARRAY=() 31 | for ARG in "${SWIFT_LIB_FILES[@]}"; do 32 | ARRAY+=("$BUILD_FOLDER/$ARG") 33 | done 34 | 35 | if [[ $MAJOR_VERSION -ge 6 ]]; then 36 | BUILD_FOLDER+="/Modules" 37 | SWIFT_LIB_FILES=($(ls "$BUILD_FOLDER")) 38 | for ARG in "${SWIFT_LIB_FILES[@]}"; do 39 | ARRAY+=("$BUILD_FOLDER/$ARG") 40 | done 41 | fi 42 | 43 | cp -fr "${ARRAY[@]}" "$LIB_INSTALL_PATH" 2>/dev/null || : 44 | 45 | sed -e "s/$DANGER_LIB_DYNAMIC_DECLARATION/$DANGER_LIB_DECLARATION/g" Package.swift > tmpPackage 46 | mv -f tmpPackage Package.swift -------------------------------------------------------------------------------- /Scripts/release_changelog.sh: -------------------------------------------------------------------------------- 1 | TEXT=`cat CHANGELOG.md| sed -n "/##\ $VERSION/,/##/p"` 2 | 3 | TEXT=`echo "$TEXT" | sed '1d;$d' | sed 's/\[\]//g'` 4 | 5 | gh release create $VERSION -n "$TEXT" 6 | -------------------------------------------------------------------------------- /Scripts/release_swiftlint_docker.sh: -------------------------------------------------------------------------------- 1 | sed -E "s/# (.*) # swiftlint/\1 # swiftlint/" Dockerfile > Dockerfile2 && mv Dockerfile2 Dockerfile 2 | -------------------------------------------------------------------------------- /Scripts/update_changelog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sed "s/## Master/\\$(printf '## Master\\\n\\\n## '"$VERSION")/" CHANGELOG.md > tmpCHANGELOG.md 4 | mv -f tmpCHANGELOG.md CHANGELOG.md -------------------------------------------------------------------------------- /Scripts/update_danger_version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SEMVER_REGEX="DangerVersion\ =\ \"[0-9]*\.[0-9]*\.[0-9]*\"" 4 | sed "s/$SEMVER_REGEX/DangerVersion = \"$VERSION\"/" Sources/Runner/main.swift > tmpMain 5 | mv -f tmpMain Sources/Runner/main.swift -------------------------------------------------------------------------------- /Scripts/update_docs.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require 'json' 4 | 5 | # Derive the lib dirs from via xcode 6 | debug_dir = `xcodebuild -project ./danger-swift.xcodeproj -showBuildSettings -configuration Debug | grep -m 1 "CONFIGURATION_BUILD_DIR" | grep -oEi "\/.*"`.strip 7 | sdk_dir = `xcodebuild -project ./danger-swift.xcodeproj -showBuildSettings -configuration Debug | grep -m 1 "SDKROOT" | grep -oEi "\/.*"`.strip 8 | tmp_dir = `xcodebuild -project ./danger-swift.xcodeproj -showBuildSettings -configuration Debug | grep -m 1 "PROJECT_TEMP_ROOT" | grep -oEi "\/.*"`.strip 9 | 10 | # [DEBUG_ROOT] = /Users/ortatherox/Library/Developer/Xcode/DerivedData/danger-swift-gjxkqkosrlvhmfflfokkehwkoffv/Build/Products/Debug 11 | # [SDK_ROOT] = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk 12 | 13 | # Apply them to the template to make a request to SourceKit 14 | # See: https://github.com/jpsim/SourceKitten/issues/405 15 | # 16 | template = File.read("Scripts/data/request.template.yml") 17 | file = template 18 | .gsub("[DEBUG_ROOT]", debug_dir) 19 | .gsub("[SDK_ROOT]", sdk_dir) 20 | .gsub("[CWD]", Dir.pwd) 21 | .gsub("[TMP_DIR]", tmp_dir) 22 | 23 | File.write("Scripts/data/request.yml", file) 24 | 25 | # Run it, get JSON back 26 | response = `swift run sourcekitten request --yaml Scripts/data/request.yml` 27 | interface = JSON.parse(response) 28 | 29 | # Write just the interface all to a file, in theory we can make a HTML version of this in the future 30 | File.write("Documentation/Reference/Danger.swift", interface["key.sourcetext"]) 31 | 32 | # Format the updated file 33 | `swift run swiftformat Documentation/Reference/Danger.swift` 34 | -------------------------------------------------------------------------------- /Scripts/update_makefile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SEMVER_REGEX="VERSION\ =\ [0-9]*\.[0-9]*\.[0-9]*" 4 | sed "s/$SEMVER_REGEX/VERSION = $VERSION/" Makefile > tmpMakefile 5 | mv -f tmpMakefile Makefile -------------------------------------------------------------------------------- /Sources/Danger-Swift/Fake.swift: -------------------------------------------------------------------------------- 1 | // An empty file to allow the DangerDependencies target to build via SPM 2 | -------------------------------------------------------------------------------- /Sources/Danger/BitBucketMetadata.swift: -------------------------------------------------------------------------------- 1 | public struct BitBucketMetadata: Decodable, Equatable { 2 | /// The PR's ID 3 | public var pullRequestID: String 4 | /// The complete repo slug including project slug. 5 | public var repoSlug: String 6 | } 7 | -------------------------------------------------------------------------------- /Sources/Danger/DangerDSL.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import OctoKit 3 | 4 | // http://danger.systems/js/reference.html 5 | 6 | // MARK: - DangerDSL 7 | 8 | public struct DSL: Decodable { 9 | /// The root danger import 10 | public let danger: DangerDSL 11 | } 12 | 13 | public struct DangerDSL: Decodable { 14 | public let git: Git 15 | 16 | public private(set) var github: GitHub! 17 | 18 | public let bitbucketCloud: BitBucketCloud! 19 | 20 | public let bitbucketServer: BitBucketServer! 21 | 22 | public let gitLab: GitLab! 23 | 24 | public let utils: DangerUtils 25 | 26 | enum CodingKeys: String, CodingKey { 27 | case git 28 | case github 29 | case bitbucketServer = "bitbucket_server" 30 | case bitbucketCloud = "bitbucket_cloud" 31 | case gitlab 32 | case settings 33 | // Used by plugin testing only 34 | // See: githubJSONWithFiles 35 | case fileMap 36 | } 37 | 38 | public init(from decoder: Decoder) throws { 39 | let container = try decoder.container(keyedBy: CodingKeys.self) 40 | git = try container.decode(Git.self, forKey: .git) 41 | github = try container.decodeIfPresent(GitHub.self, forKey: .github) 42 | bitbucketServer = try container.decodeIfPresent(BitBucketServer.self, forKey: .bitbucketServer) 43 | bitbucketCloud = try container.decodeIfPresent(BitBucketCloud.self, forKey: .bitbucketCloud) 44 | gitLab = try container.decodeIfPresent(GitLab.self, forKey: .gitlab) 45 | 46 | let settings = try container.decode(Settings.self, forKey: .settings) 47 | 48 | // File map is used so that libraries can make tests without 49 | // doing a lot of internal hacking for danger, or weird DI in their 50 | // own code. A bit of a trade-off in complexity for Danger Swift, but I 51 | // think if it leads to more tested plugins, it's a good spot to be in. 52 | if let fileMap = try container.decodeIfPresent([String: String].self, forKey: .fileMap) { 53 | utils = DangerUtils(fileMap: fileMap) 54 | } else { 55 | utils = DangerUtils(fileMap: [:]) 56 | } 57 | 58 | // Setup the OctoKit once all other 59 | if runningOnGithub { 60 | let config: TokenConfiguration 61 | 62 | if let baseURL = settings.github.baseURL { 63 | config = TokenConfiguration(settings.github.accessToken, url: baseURL) 64 | } else { 65 | config = TokenConfiguration(settings.github.accessToken) 66 | } 67 | 68 | github.api = Octokit(config) 69 | } 70 | } 71 | } 72 | 73 | extension DangerDSL { 74 | var runningOnGithub: Bool { 75 | github != nil 76 | } 77 | 78 | var runningOnBitbucketServer: Bool { 79 | bitbucketServer != nil 80 | } 81 | 82 | var supportsSuggestions: Bool { 83 | runningOnGithub 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Sources/Danger/DangerResults.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // MARK: - Violation 4 | 5 | /// The result of a warn, message, or fail. 6 | public struct Violation: Encodable { 7 | let message: String 8 | let file: String? 9 | let line: Int? 10 | 11 | init(message: String, file: String? = nil, line: Int? = nil) { 12 | self.message = message 13 | self.file = file 14 | self.line = line 15 | } 16 | } 17 | 18 | /// Meta information for showing in the text info 19 | public struct Meta: Encodable { 20 | let runtimeName: String 21 | let runtimeHref: String 22 | 23 | public init( 24 | runtimeName: String = "Danger Swift", 25 | runtimeHref: String = "https://danger.systems/swift" 26 | ) { 27 | self.runtimeName = runtimeName 28 | self.runtimeHref = runtimeHref 29 | } 30 | } 31 | 32 | // MARK: - Results 33 | 34 | /// The representation of what running a Dangerfile generates. 35 | struct DangerResults: Encodable { 36 | /// Failed messages. 37 | var fails = [Violation]() 38 | 39 | /// Messages for info. 40 | var warnings = [Violation]() 41 | 42 | /// A set of messages to show inline. 43 | var messages = [Violation]() 44 | 45 | /// Markdown messages to attach at the bottom of the comment. 46 | var markdowns = [Violation]() 47 | 48 | /// Information to pass back to Danger JS about the runtime 49 | var meta = Meta() 50 | } 51 | -------------------------------------------------------------------------------- /Sources/Danger/Extensions/NSRegularExpressionExtensions.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension NSRegularExpression { 4 | func firstMatchingString(in string: String) -> String? { 5 | let searchRange = NSRange(0 ..< string.count) 6 | 7 | guard 8 | let match = firstMatch(in: string, options: [], range: searchRange), 9 | let matchRange = Range(match.range, in: string) 10 | else { 11 | return nil 12 | } 13 | 14 | return String(string[matchRange]) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Sources/Danger/File.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // MARK: - File 4 | 5 | /// A simple typealias for strings representing files 6 | public typealias File = String 7 | 8 | public extension File { 9 | var fileType: FileType? { 10 | FileType(from: self) 11 | } 12 | 13 | var name: String { 14 | String(self) 15 | } 16 | } 17 | 18 | // MARK: - FileType 19 | 20 | public enum FileType: String, Equatable, CaseIterable { 21 | // swiftlint:disable:next identifier_name 22 | case h, json, m, markdown = "md", mm, pbxproj, plist, storyboard, swift, xcscheme, yaml, yml 23 | } 24 | 25 | // MARK: - FileType extensions 26 | 27 | extension FileType { 28 | public var `extension`: String { 29 | rawValue 30 | } 31 | 32 | init?(from file: File) { 33 | let splittedPath = file.split(separator: ".") 34 | 35 | guard let fileTypeString = splittedPath.last, 36 | splittedPath.count > 1 37 | else { 38 | return nil 39 | } 40 | 41 | self.init(rawValue: String(fileTypeString)) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Sources/Danger/GitDSL.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // swiftlint:disable nesting 4 | 5 | /// The git specific metadata for a pull request. 6 | public struct Git: Decodable, Equatable { 7 | enum CodingKeys: String, CodingKey { 8 | case modifiedFiles = "modified_files" 9 | case createdFiles = "created_files" 10 | case deletedFiles = "deleted_files" 11 | case commits 12 | } 13 | 14 | /// Modified filepaths relative to the git root. 15 | public let modifiedFiles: [File] 16 | 17 | /// Newly created filepaths relative to the git root. 18 | public let createdFiles: [File] 19 | 20 | /// Removed filepaths relative to the git root. 21 | public let deletedFiles: [File] 22 | 23 | public let commits: [Commit] 24 | } 25 | 26 | public extension Git { 27 | /// A platform agnostic reference to a git commit. 28 | struct Commit: Equatable { 29 | /// The author of a commit. 30 | public struct Author: Equatable { 31 | /// The display name for the author. 32 | public let name: String 33 | 34 | /// The email for the author. 35 | public let email: String 36 | 37 | /// The ISO8601 date string for the commit. 38 | public let date: String 39 | } 40 | 41 | /// The SHA for the commit. 42 | public let sha: String? 43 | 44 | /// Who wrote the commit. 45 | public let author: Author 46 | 47 | /// Who shipped the code. 48 | public let committer: Author 49 | 50 | /// The message for the commit. 51 | public let message: String 52 | 53 | /// SHAs for the commit's parents. 54 | public let parents: [String]? 55 | 56 | /// The URL for the commit. 57 | public let url: String? 58 | } 59 | } 60 | 61 | extension Git.Commit: Decodable {} 62 | 63 | extension Git.Commit.Author: Decodable {} 64 | -------------------------------------------------------------------------------- /Sources/Danger/Plugins/SwiftLint/CurrentPathProvider.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol CurrentPathProvider { 4 | var currentPath: String { get } 5 | } 6 | 7 | final class DefaultCurrentPathProvider: CurrentPathProvider { 8 | var currentPath: String { 9 | FileManager.default.currentDirectoryPath 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Sources/Danger/Plugins/SwiftLint/SwiftLintViolation.swift: -------------------------------------------------------------------------------- 1 | public struct SwiftLintViolation: Decodable { 2 | public enum Severity: String, Decodable { 3 | case warning = "Warning" 4 | case error = "Error" 5 | } 6 | 7 | public internal(set) var ruleID: String 8 | public internal(set) var reason: String 9 | public internal(set) var line: Int 10 | public internal(set) var severity: Severity 11 | public internal(set) var file: String 12 | 13 | var messageText: String { 14 | reason + " (`\(ruleID)`)" 15 | } 16 | 17 | enum CodingKeys: String, CodingKey { 18 | case ruleID = "rule_id" 19 | case reason, line, file, severity 20 | } 21 | 22 | public func toMarkdown() -> String { 23 | let formattedFile = file.split(separator: "/").last.map { "\($0):\(line)" } ?? "" 24 | return "\(severity.rawValue) | \(formattedFile) | \(messageText) |" 25 | } 26 | } 27 | 28 | /* 29 | "rule_id" : "opening_brace", 30 | "reason" : "Opening braces should be preceded by a single space and on the same line as the declaration.", 31 | "character" : 39, 32 | "file" : "\/Users\/ash\/bin\/Harvey\/Sources\/Harvey\/Harvey.swift", 33 | "severity" : "Warning", 34 | "type" : "Opening Brace Spacing", 35 | "line" : 8 36 | */ 37 | -------------------------------------------------------------------------------- /Sources/Danger/Plugins/SwiftLint/SwiftlintReportDeleter.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol SwiftlintReportDeleting { 4 | func deleteReport(atPath path: String) throws 5 | } 6 | 7 | struct SwiftlintReportDeleter: SwiftlintReportDeleting { 8 | let fileManager: FileManager 9 | 10 | init(fileManager: FileManager = .default) { 11 | self.fileManager = fileManager 12 | } 13 | 14 | func deleteReport(atPath path: String) throws { 15 | try fileManager.removeItem(atPath: path) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sources/Danger/Settings.swift: -------------------------------------------------------------------------------- 1 | struct Settings: Decodable { 2 | let github: GitHubSettings 3 | } 4 | 5 | struct GitHubSettings: Decodable { 6 | let accessToken: String 7 | let baseURL: String? 8 | } 9 | -------------------------------------------------------------------------------- /Sources/DangerDependenciesResolver/Data+Encoding.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension Data { 4 | func decoded() throws -> T { 5 | let decoder = JSONDecoder() 6 | return try decoder.decode(T.self, from: self) 7 | } 8 | } 9 | 10 | extension Encodable { 11 | func encoded() throws -> Data { 12 | let encoder = JSONEncoder() 13 | return try encoder.encode(self) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Sources/DangerDependenciesResolver/FileCreator.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol FileCreating { 4 | func createFile(atPath path: String, contents: Data) 5 | } 6 | 7 | struct FileCreator: FileCreating { 8 | func createFile(atPath path: String, contents: Data) { 9 | FileManager.default.createFile(atPath: path, contents: contents, attributes: [:]) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Sources/DangerDependenciesResolver/FileReader.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol FileReading { 4 | func readData(atPath: String) throws -> Data 5 | func readText(atPath: String) throws -> String 6 | } 7 | 8 | struct FileReader: FileReading { 9 | func readData(atPath path: String) throws -> Data { 10 | try Data(contentsOf: URL(fileURLWithPath: path)) 11 | } 12 | 13 | func readText(atPath path: String) throws -> String { 14 | try String(contentsOfFile: path) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Sources/DangerDependenciesResolver/PackageListMaker.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | protocol PackageListMaking { 4 | func makePackageList() -> [Package] 5 | } 6 | 7 | struct PackageListMaker: PackageListMaking { 8 | let folder: String 9 | let fileManager: FileManager 10 | let dataReader: FileReading 11 | 12 | func makePackageList() -> [Package] { 13 | files(onFolder: folder).compactMap { 14 | try? dataReader.readData(atPath: $0).decoded() 15 | } 16 | } 17 | 18 | private func files(onFolder folder: String) -> [String] { 19 | (try? fileManager.contentsOfDirectory(atPath: folder).sorted().map(folder.appendingPath)) ?? [] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Sources/DangerDependenciesResolver/URL+RemoteRepository.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension URL { 4 | var isForRemoteRepository: Bool { 5 | absoluteString.hasSuffix(".git") 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Sources/DangerFixtures/DangerDSLResources/DSLGitLabGroupMilestone.swift: -------------------------------------------------------------------------------- 1 | public let DSLGitLabGroupMilestoneJSON = """ 2 | { 3 | "id": 1672771, 4 | "iid": 1, 5 | "group_id": 9449452, 6 | "title": "Group Milestone", 7 | "description": "", 8 | "state": "active", 9 | "created_at": "2020-10-13T00:06:28.047Z", 10 | "updated_at": "2020-10-13T00:25:26.099Z", 11 | "due_date": null, 12 | "start_date": null, 13 | "expired": null, 14 | "web_url": "https://gitlab.com/groups/groupname/-/milestones/1" 15 | } 16 | """ 17 | -------------------------------------------------------------------------------- /Sources/DangerFixtures/DangerDSLResources/DSLGitLabProjectMilestone.swift: -------------------------------------------------------------------------------- 1 | public let DSLGitLabProjectMilestoneJSON = """ 2 | { 3 | "id": 1672801, 4 | "iid": 1, 5 | "project_id": 21265694, 6 | "title": "Project Milestone", 7 | "description": "", 8 | "state": "active", 9 | "created_at": "2020-10-13T00:23:21.267Z", 10 | "updated_at": "2020-10-13T00:23:21.267Z", 11 | "due_date": null, 12 | "start_date": null, 13 | "expired": null, 14 | "web_url": "https://gitlab.com/groupname/projectname/-/milestones/1" 15 | } 16 | """ 17 | -------------------------------------------------------------------------------- /Sources/DangerFixtures/DangerFixtures.swift: -------------------------------------------------------------------------------- 1 | import Danger 2 | import Foundation 3 | 4 | /// A function to set up a Danger DSL from a JSON string, 5 | /// you can use Danger JS to generate the JSON strings by using 6 | /// 7 | /// danger pr --json [pr_url] 8 | /// 9 | /// e.g. danger pr --json https://github.com/danger/swift/pull/65 --dangerfile Dangerfile.swift 10 | /// 11 | /// as this is a testing util, it is assumed you've set it up with 12 | /// working fixtured or it will raise an exception. 13 | /// 14 | /// - Parameter body: a string representing the JSON from danger pr 15 | /// - Returns: a DangerDSL 16 | /// 17 | public func parseDangerDSL(with body: String) -> DangerDSL { 18 | let dslJSONContents = Data(body.utf8) 19 | let decoder = JSONDecoder() 20 | decoder.dateDecodingStrategy = .custom(DateFormatter.dateFormatterHandler) 21 | return try! decoder.decode(DSL.self, from: dslJSONContents).danger // swiftlint:disable:this force_try 22 | } 23 | 24 | /// An example DSL using GitHub 25 | public let githubFixtureDSL = parseDangerDSL(with: DSLGitHubJSON) 26 | /// An example DSL using GitHub Enterprise 27 | public let githubEnterpriseFixtureDSL = parseDangerDSL(with: DSLGitHubEnterpriseJSON) 28 | /// An example DSL using BitBucket Server 29 | public let bitbucketFixtureDSL = parseDangerDSL(with: DSLBitBucketServerJSON) 30 | /// An example DSL without public field in fromRef using BitBucket Sever 31 | public let bitbucketForkedRepoFixtureDSL = parseDangerDSL(with: DSLBitBucketServerForkedRepoJSON) 32 | /// An example DSL using GitLab 33 | public let gitlabFixtureDSL = parseDangerDSL(with: DSLGitLabJSON) 34 | /// An example DSL without milestone date range using GitLab 35 | public let gitlabMilestoneNoDateRangeFixtureDSL = parseDangerDSL(with: DSLGitLabMilestoneNoDateRangeJSON) 36 | /// An example DSL using BitBucket Cloud 37 | public let bitbucketCloudFixtureDSL = parseDangerDSL(with: DSLBitBucketCloudJSON) 38 | /// An example DSL using GitHub 39 | public func githubWithFilesDSL(created: [File] = [], 40 | modified: [File] = [], 41 | deleted: [File] = [], 42 | fileMap: [String: String] = [:]) -> DangerDSL 43 | { 44 | parseDangerDSL(with: githubJSONWithFiles(created: created, 45 | modified: modified, 46 | deleted: deleted, 47 | fileMap: fileMap)) 48 | } 49 | -------------------------------------------------------------------------------- /Sources/Runner/Commands/Edit.swift: -------------------------------------------------------------------------------- 1 | import DangerDependenciesResolver 2 | import Foundation 3 | import Logger 4 | import RunnerLib 5 | 6 | func editDanger(version dangerSwiftVersion: String, logger: Logger) throws { 7 | let fileManager = FileManager.default 8 | let dangerfilePath: String 9 | 10 | if let dangerfileArgumentPath = DangerfilePathFinder.dangerfilePath() { 11 | dangerfilePath = dangerfileArgumentPath.fullPath 12 | } else { 13 | dangerfilePath = (Runtime.getDangerfile() ?? "Dangerfile.swift").fullPath 14 | } 15 | 16 | if !fileManager.fileExists(atPath: dangerfilePath) { 17 | createDangerfile(dangerfilePath) 18 | } 19 | 20 | let absoluteLibPath: String 21 | let libsImport: [String] 22 | 23 | if let spmDanger = SPMDanger() { 24 | spmDanger.buildDependencies() 25 | absoluteLibPath = spmDanger.buildFolder 26 | libsImport = spmDanger.xcodeImportFlags 27 | } else { 28 | guard let libPath = Runtime.getLibDangerPath(forDangerSwiftVersion: dangerSwiftVersion) else { 29 | let potentialFolders = Runtime.potentialLibraryFolders(forDangerSwiftVersion: dangerSwiftVersion) 30 | logger.logError("Could not find a libDanger to link against at any of: \(potentialFolders)", 31 | "Or via Homebrew, or Marathon, or Mise", 32 | separator: "\n") 33 | exit(1) 34 | } 35 | absoluteLibPath = libPath.fullPath 36 | libsImport = ["-l Danger"] 37 | } 38 | 39 | guard let dangerfileContent = try? String(contentsOfFile: dangerfilePath) else { 40 | logger.logError("Could not read the dangerPath") 41 | exit(1) 42 | } 43 | 44 | let importsFinder = ImportsFinder() 45 | let importedFiles = importsFinder.findImports(inString: dangerfileContent) 46 | .map { importsFinder.resolveImportPath($0, relativeTo: dangerfilePath) } 47 | 48 | let scriptManager = try getScriptManager(forDangerSwiftVersion: dangerSwiftVersion, 49 | logger: logger) 50 | let script = try scriptManager.script(atPath: dangerfilePath) 51 | 52 | try script.setupForEdit(importedFiles: importedFiles) 53 | try script.watch(importedFiles: importedFiles) 54 | } 55 | 56 | private func createDangerfile(_ dangerfilePath: String) { 57 | let template = "import Danger \nlet danger = Danger()" 58 | let data = Data(template.utf8) 59 | 60 | FileManager.default.createFile(atPath: dangerfilePath, contents: data, attributes: [:]) 61 | } 62 | -------------------------------------------------------------------------------- /Sources/Runner/Commands/RunDangerJS.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Logger 3 | import RunnerLib 4 | #if canImport(FoundationNetworking) 5 | import FoundationNetworking 6 | #endif 7 | 8 | func runDangerJSCommandToRunDangerSwift(_ command: DangerCommand, logger: Logger) throws -> Int32 { 9 | guard let dangerJS = try? getDangerCommandPath(logger: logger) else { 10 | logger.logError("Danger JS was not found on the system", 11 | "Please install it with npm or brew", 12 | separator: "\n") 13 | exit(1) 14 | } 15 | 16 | let dangerJSVersion = DangerJSVersionFinder.findDangerJSVersion(dangerJSPath: dangerJS) 17 | 18 | guard dangerJSVersion.compare(MinimumDangerJSVersion, options: .numeric) != .orderedAscending else { 19 | logger.logError("The installed danger-js version is below the minimum supported version", 20 | "Current version = \(dangerJSVersion)", 21 | "Minimum supported version = \(MinimumDangerJSVersion)", 22 | separator: "\n") 23 | exit(1) 24 | } 25 | 26 | let proc = Process() 27 | proc.environment = ProcessInfo.processInfo.environment 28 | proc.executableURL = URL(fileURLWithPath: dangerJS) 29 | 30 | let dangerOptionsIndexes = DangerSwiftOption.allCases 31 | .compactMap { option -> (DangerSwiftOption, Int)? in 32 | if let index = CommandLine.arguments.firstIndex(of: option.rawValue) { 33 | return (option, index) 34 | } else { 35 | return nil 36 | } 37 | } 38 | 39 | let unusedArgs = CommandLine.arguments.enumerated().compactMap { index, arg -> String? in 40 | if dangerOptionsIndexes.contains(where: { index == $0.1 || ($0.0.hasParameter && index == $0.1 + 1) }) { 41 | return nil 42 | } 43 | 44 | if arg.contains("danger-swift") || arg == command.rawValue { 45 | return nil 46 | } 47 | 48 | return arg 49 | } 50 | 51 | var dangerSwiftCommand = "danger-swift" 52 | // Special-case running inside the danger dev dir 53 | let fileManager = FileManager.default 54 | if fileManager.fileExists(atPath: ".build/debug/danger-swift") { 55 | dangerSwiftCommand = ".build/debug/danger-swift" 56 | } else if let firstArg = CommandLine.arguments.first, 57 | fileManager.fileExists(atPath: firstArg) 58 | { 59 | dangerSwiftCommand = firstArg 60 | } 61 | 62 | proc.arguments = [command.rawValue, "--process", dangerSwiftCommand, "--passURLForDSL"] + unusedArgs 63 | 64 | let standardOutput = FileHandle.standardOutput 65 | proc.standardOutput = standardOutput 66 | proc.standardError = standardOutput 67 | 68 | logger.debug("Running: \(proc.executableURL!) \(proc.arguments!.joined(separator: " ")) ") 69 | try proc.run() 70 | proc.waitUntilExit() 71 | 72 | return proc.terminationStatus 73 | } 74 | -------------------------------------------------------------------------------- /Sources/Runner/MarathonScriptManager.swift: -------------------------------------------------------------------------------- 1 | import DangerDependenciesResolver 2 | import Foundation 3 | import Logger 4 | 5 | func getScriptManager(forDangerSwiftVersion dangerSwiftVersion: String, 6 | logger: Logger) throws -> ScriptManager 7 | { 8 | let homeFolder: String 9 | 10 | if #available(OSX 10.12, *) { 11 | homeFolder = FileManager.default.homeDirectoryForCurrentUser.path 12 | } else { 13 | homeFolder = NSHomeDirectory() 14 | } 15 | 16 | let folder = "\(homeFolder)/.danger-swift/" 17 | 18 | let packageFolder = folder + "Packages/" 19 | let scriptFolder = folder + "Scripts/" 20 | 21 | let packageManager = try PackageManager(folder: packageFolder, logger: logger) 22 | 23 | return try ScriptManager(folder: scriptFolder, 24 | dangerSwiftVersion: dangerSwiftVersion, 25 | packageManager: packageManager, 26 | logger: logger) 27 | } 28 | -------------------------------------------------------------------------------- /Sources/Runner/main.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Logger 3 | import RunnerLib 4 | 5 | /// Version for showing in verbose mode 6 | let DangerVersion = "3.21.2" // swiftlint:disable:this identifier_name 7 | let MinimumDangerJSVersion = "6.1.6" // swiftlint:disable:this identifier_name 8 | 9 | private func runCommand(_ command: DangerCommand, logger: Logger) throws { 10 | switch command { 11 | case .ci, .local, .pr: 12 | let exitCode = try runDangerJSCommandToRunDangerSwift(command, logger: logger) 13 | checkForUpdate(logger: logger) 14 | exit(exitCode) 15 | case .edit: 16 | try editDanger(version: DangerVersion, logger: logger) 17 | case .runner: 18 | try runDanger(version: DangerVersion, logger: logger) 19 | } 20 | } 21 | 22 | private func checkForUpdate(logger: Logger) { 23 | let versionChecker = VersionChecker(logger: logger, env: ProcessInfo.processInfo.environment) 24 | versionChecker.checkForUpdate(current: DangerVersion) 25 | } 26 | 27 | let cliLength = ProcessInfo.processInfo.arguments.count 28 | let isVerbose = CommandLine.arguments.contains("--verbose") || (ProcessInfo.processInfo.environment["DEBUG"] != nil) 29 | let isSilent = CommandLine.arguments.contains("--silent") 30 | let logger = Logger(isVerbose: isVerbose, isSilent: isSilent) 31 | 32 | guard !CommandLine.arguments.contains("--version") else { 33 | logger.logInfo(DangerVersion) 34 | exit(0) 35 | } 36 | 37 | do { 38 | if cliLength > 1 { 39 | logger.debug("Launching Danger Swift \(CommandLine.arguments[1]) (v\(DangerVersion))") 40 | 41 | let command = DangerCommand(rawValue: CommandLine.arguments[1]) 42 | 43 | guard !CommandLine.arguments.contains("--help") else { 44 | HelpMessagePresenter.showHelpMessage(command: command, logger: logger) 45 | exit(0) 46 | } 47 | 48 | if command != nil { 49 | try runCommand(command!, logger: logger) 50 | } else { 51 | fatalError("Danger Swift does not support this argument, it only handles ci, local, pr & edit'") 52 | } 53 | } else { 54 | try runDanger(version: DangerVersion, logger: logger) 55 | } 56 | } catch { 57 | logger.logError(error) 58 | exit(1) 59 | } 60 | -------------------------------------------------------------------------------- /Sources/RunnerLib/CliArgs/CliArgs.swift: -------------------------------------------------------------------------------- 1 | // Describes the possible arguments that could be used when calling the CLI 2 | public struct CliArgs { 3 | // So you can have many danger runs in one code review 4 | public let id: String? 5 | 6 | // The base reference used by danger PR (e.g. not master) 7 | public let base: String? 8 | 9 | // For debugging 10 | public let verbose: String? 11 | 12 | // Used by danger-js o allow having a custom CI 13 | public let externalCiProvider: String? 14 | 15 | // textOnly 16 | public let textOnly: String? 17 | 18 | // A custom path for the dangerfile (can also be a remote reference) 19 | public let dangerfile: String? 20 | 21 | fileprivate enum CodingKeys: String { 22 | case id 23 | case base 24 | case verbose 25 | case externalCiProvider 26 | case textOnly 27 | case dangerfile 28 | } 29 | 30 | init(dictionary: [String: Any]) { 31 | id = dictionary[.id] as? String 32 | base = dictionary[.base] as? String 33 | verbose = dictionary[.verbose] as? String 34 | externalCiProvider = dictionary[.externalCiProvider] as? String 35 | textOnly = dictionary[.textOnly] as? String 36 | dangerfile = dictionary[.dangerfile] as? String 37 | } 38 | } 39 | 40 | private extension Dictionary where Key == String { 41 | subscript(_ codingKey: CliArgs.CodingKeys) -> Value? { 42 | self[codingKey.rawValue] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Sources/RunnerLib/CliArgs/CliArgsParser.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public final class CliArgsParser { 4 | public init() {} 5 | 6 | public func parseCli(fromData data: Data) -> CliArgs? { 7 | if let dictionary = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [String: Any], 8 | let danger = dictionary["danger"] as? [String: Any], 9 | let settings = danger["settings"] as? [String: Any], 10 | let cliArgsDictionary = settings["cliArgs"] as? [String: Any] 11 | { 12 | return CliArgs(dictionary: cliArgsDictionary) 13 | } 14 | 15 | return nil 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sources/RunnerLib/DangerCommand.swift: -------------------------------------------------------------------------------- 1 | public enum DangerCommand: String, CaseIterable { 2 | case ci 3 | case local 4 | case pr 5 | case edit 6 | case runner 7 | 8 | var commandDescription: String { 9 | switch self { 10 | case .ci: 11 | return "Use this on CI" 12 | case .edit: 13 | return "Creates a temporary Xcode project for working on a Dangerfile" 14 | case .local: 15 | return "Use this to run danger against your local changes from master" 16 | case .pr: 17 | return "Run danger-swift locally against a PR" 18 | case .runner: 19 | return "Use this to trigger the Dangerfile evaluation" 20 | } 21 | } 22 | 23 | public static var commandsListText: String { 24 | allCases.reduce("") { result, command -> String in 25 | result + command.rawValue + "\t" + command.commandDescription + "\n" 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Sources/RunnerLib/DangerJSVersionFinder.swift: -------------------------------------------------------------------------------- 1 | import DangerShellExecutor 2 | import Logger 3 | 4 | public enum DangerJSVersionFinder { 5 | public static func findDangerJSVersion(dangerJSPath: String) -> String { 6 | findDangerJSVersion(dangerJSPath: dangerJSPath, executor: ShellExecutor()) 7 | } 8 | 9 | static func findDangerJSVersion(dangerJSPath: String, executor: ShellExecuting) -> String { 10 | Logger().debug("Finding danger-js version") 11 | 12 | return executor.execute(dangerJSPath, arguments: ["--version"]) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Sources/RunnerLib/DangerSwiftOption.swift: -------------------------------------------------------------------------------- 1 | // Options handled directly by Danger swift and not sent back to Danger JS 2 | 3 | public enum DangerSwiftOption: String, CaseIterable { 4 | case dangerJSPath = "--danger-js-path" 5 | 6 | public var hasParameter: Bool { 7 | switch self { 8 | case .dangerJSPath: 9 | return true 10 | } 11 | } 12 | } 13 | 14 | public enum DangeSwiftRunnerOption: String, CaseIterable { 15 | case cwd = "--cwd" 16 | 17 | public var hasParameter: Bool { 18 | switch self { 19 | case .cwd: 20 | return true 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Sources/RunnerLib/DangerfileArgumentsPath.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public enum DangerfilePathFinder { 4 | public static func dangerfilePath(fromArguments arguments: [String] = CommandLine.arguments) -> String? { 5 | guard let dangerfileArgIndex = arguments.firstIndex(of: "--dangerfile"), 6 | dangerfileArgIndex + 1 < arguments.count 7 | else { 8 | return nil 9 | } 10 | 11 | return arguments[dangerfileArgIndex + 1] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Sources/RunnerLib/Files Import/DangerFileGenerator.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import Logger 3 | 4 | public final class DangerFileGenerator { 5 | public init() {} 6 | 7 | public func generateDangerFile(fromContent content: String, fileName: String, logger: Logger) throws { 8 | var dangerContent = content 9 | let importsRegex = NSRegularExpression.filesImportRegex 10 | let range = NSRange(location: 0, length: content.count) 11 | 12 | importsRegex.enumerateMatches(in: content, options: [], range: range, using: { result, _, _ in 13 | // Adjust the result to have the correct range also after dangerContent is modified 14 | guard let result = result?.adjustingRanges(offset: 15 | dangerContent.utf16.count - content.utf16.count) else { return } 16 | let url = importsRegex.replacementString(for: result, in: dangerContent, offset: 0, template: "$1") 17 | 18 | guard let fileContent = try? String(contentsOfFile: url), 19 | let replacementRange = Range(result.range, in: dangerContent) 20 | else { 21 | logger.logWarning("File not found at \(url)") 22 | return 23 | } 24 | 25 | dangerContent.replaceSubrange(replacementRange, with: fileContent) 26 | }) 27 | 28 | mergeImports(in: &dangerContent) 29 | 30 | try dangerContent.write(toFile: fileName, atomically: false, encoding: .utf8) 31 | } 32 | } 33 | 34 | private extension DangerFileGenerator { 35 | func mergeImports(in content: inout String) { 36 | var lines = content 37 | .split(separator: "\n", 38 | omittingEmptySubsequences: false) 39 | .map(String.init) 40 | 41 | let imports = Set( 42 | lines.map { $0.trimmingCharacters(in: .whitespaces) } 43 | .filter { $0.hasPrefix("import ") } 44 | ) 45 | lines.removeAll { imports.contains($0.trimmingCharacters(in: .whitespaces)) } 46 | lines.insert(contentsOf: imports.sorted(), at: 0) 47 | content = lines.joined(separator: "\n") 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Sources/RunnerLib/Files Import/ImportsFinder.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public final class ImportsFinder { 4 | public init() {} 5 | 6 | public func findImports(inString string: String) -> [String] { 7 | let regex = NSRegularExpression.filesImportRegex 8 | let matches = regex.matches(in: string, options: [], range: NSRange(location: 0, length: string.count)) 9 | let files = matches.map { regex.replacementString(for: $0, in: string, offset: 0, template: "$1") } 10 | 11 | return files 12 | } 13 | 14 | public func resolveImportPath(_ path: String, 15 | relativeTo dangerfilePath: String) -> String 16 | { 17 | dangerfilePath 18 | .removingLastPathComponent() 19 | .appendingPath(path) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Sources/RunnerLib/GetDangerJSPath.swift: -------------------------------------------------------------------------------- 1 | import DangerShellExecutor 2 | import Foundation 3 | import Logger 4 | 5 | public func getDangerCommandPath(logger: Logger, 6 | args: [String] = CommandLine.arguments, 7 | shellOutExecutor: ShellExecuting = ShellExecutor()) throws -> String 8 | { 9 | if let dangerJSPathOptionIndex = args.firstIndex(of: DangerSwiftOption.dangerJSPath.rawValue), 10 | dangerJSPathOptionIndex + 1 < args.count 11 | { 12 | return args[dangerJSPathOptionIndex + 1] 13 | } else { 14 | logger.debug("Finding out where the danger executable is") 15 | 16 | if let dangerJsPath = try? shellOutExecutor.spawn("command -v danger-js", 17 | arguments: []).trimmingCharacters(in: .whitespaces), 18 | !dangerJsPath.isEmpty 19 | { 20 | return dangerJsPath.deletingSuffix("-js") 21 | } else { 22 | return try shellOutExecutor.spawn("command -v danger", arguments: []).trimmingCharacters(in: .whitespaces) 23 | } 24 | } 25 | } 26 | 27 | private extension String { 28 | func deletingSuffix(_ suffix: String) -> String { 29 | guard hasSuffix(suffix) else { return self } 30 | return String(dropLast(suffix.count)) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Sources/RunnerLib/HelpMessagePresenter.swift: -------------------------------------------------------------------------------- 1 | import Logger 2 | 3 | public enum HelpMessagePresenter { 4 | public static func showHelpMessage(command: DangerCommand?, logger: Logger) { 5 | if command == nil { 6 | showCommandsList(logger: logger) 7 | } 8 | } 9 | 10 | private static func showCommandsList(logger: Logger) { 11 | logger.logInfo("danger-swift [command]") 12 | logger.logInfo("") 13 | logger.logInfo("Commands:") 14 | logger.logInfo(DangerCommand.commandsListText, separator: "", terminator: "") 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Sources/RunnerLib/NSRegularExpression+FilesImport.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | extension NSRegularExpression { 4 | private static let fileImportPattern = "\\/\\/[\\ ]?fileImport:\\ (.*)" 5 | 6 | static let filesImportRegex = try! NSRegularExpression(pattern: fileImportPattern, options: .allowCommentsAndWhitespace) 7 | } 8 | -------------------------------------------------------------------------------- /Sources/RunnerLib/Runtime.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // Bunch of Danger runtime util funcs 4 | 5 | public enum Runtime { 6 | public static let supportedPaths = [ 7 | "Dangerfile.swift", 8 | "Danger.swift", 9 | "danger/Dangerfile.swift", 10 | "Danger/Dangerfile.swift", 11 | ] 12 | 13 | /// Finds a Dangerfile from the current working directory 14 | public static func getDangerfile() -> String? { 15 | supportedPaths.first { FileManager.default.fileExists(atPath: $0) } 16 | } 17 | 18 | /// Is this a dev build: e.g. running inside a cloned danger/danger-swift 19 | public static func potentialLibraryFolders(forDangerSwiftVersion version: String) -> [String] { [ 20 | ".build/debug", // Working in Xcode / CLI 21 | ".build/x86_64-unknown-linux/debug", // Danger Swift's CI 22 | ".build/release", // Testing prod 23 | "/usr/local/lib/danger", // Intel Homebrew installs lib stuff to here 24 | "/opt/homebrew/lib/danger", // Apple Silicon Homebrew installs lib stuff to here 25 | NSHomeDirectory() + "/.local/share/mise/installs/danger-swift/\(version)/lib/danger" 26 | ] 27 | } 28 | 29 | /// Finds a path to add at runtime to the compiler, which links 30 | /// to the library Danger 31 | public static func getLibDangerPath(forDangerSwiftVersion version: String) -> String? { 32 | let fileManager = FileManager.default 33 | 34 | // Was danger-swift installed via marathon? 35 | // e.g "~/.marathon/Scripts/Temp/https:--github.com-danger-danger-swift.git/clone/.build/release" 36 | let marathonDangerDLDir = NSHomeDirectory() + "/.marathon/Scripts/Temp/" 37 | let marathonScripts = try? fileManager.contentsOfDirectory(atPath: marathonDangerDLDir) 38 | var depManagerDangerLibPaths: [String] = [] 39 | 40 | if marathonScripts != nil { 41 | // TODO: Support running from a fork? 42 | let dangerSwiftPath = marathonScripts!.first { $0.contains("danger-swift") } 43 | if dangerSwiftPath != nil { 44 | let path = marathonDangerDLDir + dangerSwiftPath! + "/clone/.build/release" 45 | depManagerDangerLibPaths.append(path) 46 | } 47 | } 48 | 49 | let commandArgPath = CommandLine.arguments.first.map { arg in 50 | [arg.removingLastPathComponent()] 51 | } ?? [] 52 | 53 | // Check and find where we can link to libDanger from 54 | let libPaths = commandArgPath + potentialLibraryFolders(forDangerSwiftVersion: version) + depManagerDangerLibPaths 55 | 56 | func isTheDangerLibPath(path: String) -> Bool { 57 | fileManager.fileExists(atPath: path + "/libDanger.dylib") || // OSX 58 | fileManager.fileExists(atPath: path + "/libDanger.so") // Linux 59 | } 60 | 61 | guard let path = libPaths.first(where: isTheDangerLibPath) else { return nil } 62 | 63 | // Always return an absolute path 64 | if path.starts(with: "/") { 65 | return path 66 | } 67 | 68 | return fileManager.currentDirectoryPath.appendingPath(path) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Sources/RunnerLib/SPMDanger.swift: -------------------------------------------------------------------------------- 1 | import DangerShellExecutor 2 | import Foundation 3 | 4 | public struct SPMDanger { 5 | private static let dangerDepsPrefix = "DangerDeps" 6 | private let fileManager: FileManager 7 | public let depsLibName: String 8 | 9 | public var buildFolder: String { 10 | fileManager.currentDirectoryPath + "/.build/debug" 11 | } 12 | 13 | public var moduleFolder: String { 14 | #if compiler(<6.0) 15 | buildFolder 16 | #else 17 | buildFolder + "/Modules" 18 | #endif 19 | } 20 | 21 | public init?( 22 | packagePath: String = "Package.swift", 23 | readFile: (String) -> String? = { try? String(contentsOfFile: $0) }, 24 | fileManager: FileManager = .default 25 | ) { 26 | self.fileManager = fileManager 27 | let packageContent = readFile(packagePath) ?? "" 28 | 29 | let regexPattern = #"\.library\([\ \n]*name:[\ ]?\"(\#(SPMDanger.dangerDepsPrefix)[A-Za-z]*)\""# 30 | let regex = try? NSRegularExpression(pattern: regexPattern, 31 | options: .allowCommentsAndWhitespace) 32 | let firstMatch = regex?.firstMatch(in: packageContent, 33 | options: [], 34 | range: NSRange(location: 0, length: packageContent.count)) 35 | 36 | if let depsLibNameRange = firstMatch?.range(at: 1), 37 | let range = Range(depsLibNameRange, in: packageContent) 38 | { 39 | depsLibName = String(packageContent[range]) 40 | } else { 41 | return nil 42 | } 43 | } 44 | 45 | public func buildDependencies(executor: ShellExecuting = ShellExecutor()) { 46 | executor.execute("swift build", arguments: ["--product \(depsLibName)"]) 47 | } 48 | 49 | public var swiftcLibImport: String { 50 | "-l\(depsLibName)" 51 | } 52 | 53 | public var xcodeImportFlags: [String] { 54 | let libsImport = ["-l \(depsLibName)"] 55 | 56 | // The danger lib is not always generated, this mainly happens on the danger repo, 57 | // where the DangerDeps library and Danger.swiftmodule are enough 58 | if fileManager.fileExists(atPath: buildFolder + "/libDanger.dylib") || 59 | fileManager.fileExists(atPath: buildFolder + "/libDanger.so") 60 | { 61 | return libsImport + ["-l Danger"] 62 | } else { 63 | return libsImport 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Sources/RunnerLib/String+Path.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | public extension String { 4 | var fullPath: String { 5 | if hasPrefix("/") { 6 | return self 7 | } else { 8 | return FileManager.default.currentDirectoryPath.appendingPath(self) 9 | } 10 | } 11 | 12 | func appendingPath(_ path: String) -> String { 13 | if hasSuffix("/") { 14 | return self + path 15 | } else { 16 | return self + "/" + path 17 | } 18 | } 19 | 20 | func removingLastPathComponent() -> String { 21 | let components = split(separator: "/") 22 | 23 | if components.count == 1 { 24 | return self 25 | } else { 26 | let result = components.dropLast().joined(separator: "/") 27 | 28 | if starts(with: "/") { 29 | return "/" + result 30 | } else { 31 | return result 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/RunnerLib/VersionChecker.swift: -------------------------------------------------------------------------------- 1 | import DangerShellExecutor 2 | import Foundation 3 | import Logger 4 | import Version 5 | 6 | public struct VersionChecker { 7 | private let shellExecutor: ShellExecuting 8 | private let logger: Logger 9 | private let env: [String: String] 10 | 11 | public init( 12 | shellExecutor: ShellExecuting = ShellExecutor(), 13 | logger: Logger, 14 | env: [String: String] 15 | ) { 16 | self.shellExecutor = shellExecutor 17 | self.logger = logger 18 | self.env = env 19 | } 20 | } 21 | 22 | public extension VersionChecker { 23 | func checkForUpdate(current currentVersionString: String) { 24 | guard env["DANGER_SWIFT_NO_UPDATE_CHECK"] == nil, env["DEBUG"] == nil else { return } 25 | guard let latestVersionString = fetchLatestVersion() else { return } 26 | guard let latestVersion = Version(latestVersionString) else { 27 | logger.debug("Invalid latestVersionString: (\(latestVersionString)") 28 | return 29 | } 30 | guard let currentVersion = Version(currentVersionString) else { 31 | logger.debug("Invalid currentVersionString: (\(currentVersionString)") 32 | return 33 | } 34 | if currentVersion < latestVersion { 35 | logger.logInfo("\nℹ️ A new release of danger-swift is available: \(currentVersion) -> \(latestVersion)") 36 | } 37 | } 38 | } 39 | 40 | private extension VersionChecker { 41 | func fetchLatestVersion() -> String? { 42 | let decoder = JSONDecoder() 43 | decoder.keyDecodingStrategy = .convertFromSnakeCase 44 | do { 45 | let latest = try shellExecutor.execute("curl", 46 | arguments: [ 47 | "-s", 48 | "https://api.github.com/repos/danger/swift/releases/latest", 49 | ]) 50 | .data(using: .utf8) 51 | .flatMap { try decoder.decode(Release.self, from: $0) } 52 | return latest?.tagName 53 | } catch { 54 | logger.debug(error) 55 | return nil 56 | } 57 | } 58 | } 59 | 60 | struct Release: Codable { 61 | var tagName: String 62 | } 63 | -------------------------------------------------------------------------------- /Tests/DangerDependenciesResolverTests/InlineDependenciesFinderTests.swift: -------------------------------------------------------------------------------- 1 | @testable import DangerDependenciesResolver 2 | import Foundation 3 | import XCTest 4 | 5 | final class InlineDependenciesFinderTests: XCTestCase { 6 | func testFindsDependencies() throws { 7 | let fileReader = StubbedDataReader(stubbedReadText: { _ -> String in 8 | self.script 9 | }) 10 | let dependenciesFinder = InlineDependenciesFinder(fileReader: fileReader, 11 | config: ScriptManager.Config(prefix: "package: ", file: "", major: "~> ")) 12 | 13 | let result = try dependenciesFinder.resolveInlineDependencies(fromPath: "path", 14 | dangerSwiftVersion: "3.0.0") 15 | 16 | XCTAssertEqual(result, [ 17 | .dangerSwift(version: "3.0.0"), 18 | InlineDependenciesFinder.InlineDependency(url: URL(string: "http://danger.systems")!, major: nil), 19 | InlineDependenciesFinder.InlineDependency(url: URL(string: "http://danger.systems/swift")!, major: 2), 20 | ]) 21 | } 22 | 23 | #if os(macOS) || compiler(<6.0) 24 | // TODO: Fix on Linux with Swift 6.0 25 | func testReturnsAnErrorWhenDependencyIsInvalid() throws { 26 | let fileReader = StubbedDataReader(stubbedReadText: { _ -> String in 27 | self.scriptWithInvalidURL 28 | }) 29 | let dependenciesFinder = InlineDependenciesFinder(fileReader: fileReader, 30 | config: ScriptManager.Config(prefix: "package: ", file: "", major: "~> ")) 31 | 32 | XCTAssertThrowsError(try dependenciesFinder.resolveInlineDependencies(fromPath: "path", dangerSwiftVersion: "3.14.0")) 33 | } 34 | #endif 35 | 36 | func testReturnsAnEmptyDependenciesListWhenDependenciesDoNotHavePackagePrefix() throws { 37 | let fileReader = StubbedDataReader(stubbedReadText: { _ -> String in 38 | self.scriptWithoutPackagePrefix 39 | }) 40 | let dependenciesFinder = InlineDependenciesFinder(fileReader: fileReader, 41 | config: ScriptManager.Config(prefix: "package: ", file: "", major: "~> ")) 42 | 43 | let result = try dependenciesFinder.resolveInlineDependencies(fromPath: "path", dangerSwiftVersion: "3.1.4") 44 | 45 | XCTAssertEqual(result, [.dangerSwift(version: "3.1.4")]) 46 | } 47 | 48 | private var script: String { 49 | """ 50 | import LibA 51 | import LibB // package: http://danger.systems 52 | import LibC // package: http://danger.systems/swift ~> 2 53 | """ 54 | } 55 | 56 | private var scriptWithInvalidURL: String { 57 | """ 58 | import LibA 59 | import LibB // package: invalid url 60 | """ 61 | } 62 | 63 | private var scriptWithoutPackagePrefix: String { 64 | """ 65 | import LibA 66 | import LibB 67 | """ 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Tests/DangerDependenciesResolverTests/PackageListMakerTests.swift: -------------------------------------------------------------------------------- 1 | @testable import DangerDependenciesResolver 2 | import XCTest 3 | 4 | final class PackageListMakerTests: XCTestCase { 5 | func testParsesValidPackages() { 6 | let expectedResult = Package(name: "test", url: URL(string: "about:blank")!, majorVersion: 5) 7 | let expectedResult2 = Package(name: "test", url: URL(string: "about:blank")!, majorVersion: 5) 8 | let dataReader = StubbedDataReader() 9 | dataReader.stubbedReadData = { path in 10 | switch path { 11 | case "/user/franco/Package1.swift": 12 | return try expectedResult.encoded() 13 | case "/user/franco/Package2.swift": 14 | return try expectedResult.encoded() 15 | case "/user/franco/File.swift": 16 | return Data() 17 | default: 18 | XCTFail("Received invalid path \(path)") 19 | return Data() 20 | } 21 | } 22 | let fileManager = StubbedFileManager() 23 | fileManager.stubbedContent = ["Package1.swift", "File.swift", "Package2.swift"] 24 | let packageListMaker = PackageListMaker(folder: "/user/franco", fileManager: fileManager, dataReader: dataReader) 25 | 26 | let packages = packageListMaker.makePackageList() 27 | 28 | XCTAssertEqual(packages, [expectedResult, expectedResult2]) 29 | } 30 | } 31 | 32 | final class StubbedFileManager: FileManager { 33 | var stubbedContent: [String] = [] 34 | 35 | override func contentsOfDirectory(atPath _: String) throws -> [String] { 36 | stubbedContent 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Tests/DangerDependenciesResolverTests/StubbedDataReader.swift: -------------------------------------------------------------------------------- 1 | @testable import DangerDependenciesResolver 2 | import Foundation 3 | 4 | final class StubbedDataReader: FileReading { 5 | var stubbedReadData: ((String) throws -> Data)! 6 | var stubbedReadText: ((String) throws -> String)! 7 | 8 | init(stubbedReadData: ((String) -> Data)? = nil, stubbedReadText: ((String) -> String)? = nil) { 9 | self.stubbedReadData = stubbedReadData 10 | self.stubbedReadText = stubbedReadText 11 | } 12 | 13 | func readData(atPath path: String) throws -> Data { 14 | try stubbedReadData(path) 15 | } 16 | 17 | func readText(atPath path: String) throws -> String { 18 | try stubbedReadText(path) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/DangerDependenciesResolverTests/__Snapshots__/PackageGeneratorTests/testGeneratedDescriptionHeader.1.txt: -------------------------------------------------------------------------------- 1 | // swift-tools-version:4.2 2 | // danger-dependency-generator-version:3 -------------------------------------------------------------------------------- /Tests/DangerDependenciesResolverTests/__Snapshots__/PackageGeneratorTests/testGeneratedPackageWhenThereAreDependencies.1.txt: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.0 2 | // danger-dependency-generator-version:3 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "PACKAGES", 8 | platforms: [.macOS(.v12)], 9 | products: [.executable(name: "DangerDependencies", targets: ["PACKAGES"])], 10 | dependencies: [ 11 | .package(url: "https://github.com/danger/dependency1", from: "1.0.0"), 12 | .package(url: "https://github.com/danger/dependency2", from: "2.0.0"), 13 | .package(url: "https://github.com/danger/dependency3", from: "3.0.0") 14 | ], 15 | targets: [.executableTarget(name: "PACKAGES", dependencies: [ 16 | "Dependency1", 17 | "Dependency2", 18 | "Dependency3" 19 | ])], 20 | swiftLanguageVersions: [.version("5")] 21 | ) -------------------------------------------------------------------------------- /Tests/DangerDependenciesResolverTests/__Snapshots__/PackageGeneratorTests/testGeneratedPackageWhenThereAreDependenciesAndSwiftVersionIs5_2.1.txt: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.2 2 | // danger-dependency-generator-version:3 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "PACKAGES", 8 | platforms: [.macOS(.v12)], 9 | products: [.executable(name: "DangerDependencies", targets: ["PACKAGES"])], 10 | dependencies: [ 11 | .package(name: "Dependency1", url: "https://github.com/danger/dependency1", from: "1.0.0"), 12 | .package(name: "Dependency2", url: "https://github.com/danger/dependency2", from: "2.0.0"), 13 | .package(name: "Dependency3", url: "https://github.com/danger/dependency3", from: "3.0.0") 14 | ], 15 | targets: [.executableTarget(name: "PACKAGES", dependencies: [ 16 | "Dependency1", 17 | "Dependency2", 18 | "Dependency3" 19 | ])], 20 | swiftLanguageVersions: [.version("5")] 21 | ) -------------------------------------------------------------------------------- /Tests/DangerDependenciesResolverTests/__Snapshots__/PackageGeneratorTests/testGeneratedPackageWhenThereAreDependenciesAndSwiftVersionIs5_6.1.txt: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.6 2 | // danger-dependency-generator-version:3 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "PACKAGES", 8 | platforms: [.macOS(.v12)], 9 | products: [.executable(name: "DangerDependencies", targets: ["PACKAGES"])], 10 | dependencies: [ 11 | .package(url: "https://github.com/danger/dependency1", from: "1.0.0"), 12 | .package(url: "https://github.com/danger/dependency2", from: "2.0.0"), 13 | .package(url: "https://github.com/danger/dependency3", from: "3.0.0") 14 | ], 15 | targets: [.executableTarget(name: "PACKAGES", dependencies: [ 16 | .product(name: "Dependency1", package: "dependency1"), 17 | .product(name: "Dependency2", package: "dependency2"), 18 | .product(name: "Dependency3", package: "dependency3") 19 | ])], 20 | swiftLanguageVersions: [.version("5")] 21 | ) -------------------------------------------------------------------------------- /Tests/DangerDependenciesResolverTests/__Snapshots__/PackageGeneratorTests/testGeneratedPackageWhenThereAreNoDependencies.1.txt: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.0 2 | // danger-dependency-generator-version:3 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "PACKAGES", 8 | platforms: [.macOS(.v12)], 9 | products: [.executable(name: "DangerDependencies", targets: ["PACKAGES"])], 10 | dependencies: [ 11 | 12 | ], 13 | targets: [.executableTarget(name: "PACKAGES", dependencies: [])], 14 | swiftLanguageVersions: [.version("5")] 15 | ) -------------------------------------------------------------------------------- /Tests/DangerTests/BitBucketServerTestResources/BitBucketServerProject.swift: -------------------------------------------------------------------------------- 1 | public let BitBucketServerProjectJSON = """ 2 | {"key":"IOSEXAMPLE","id":1666,"name":"iOS Example Projects","public":false,"type":"NORMAL","links":{"self":[{"href":"https://repobruegge.in.tum.de/projects/IOSEXAMPLE"}]}} 3 | """ 4 | -------------------------------------------------------------------------------- /Tests/DangerTests/BitBucketServerTestResources/BitBucketServerRepo.swift: -------------------------------------------------------------------------------- 1 | public let BitBucketServerRepoJSON = """ 2 | {"slug":"example-client","id":25120,"name":"Example Client","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":{"key":"IOSEXAMPLE","id":1666,"name":"iOS Example Projects","public":false,"type":"NORMAL","links":{"self":[{"href":"https://repobruegge.in.tum.de/projects/IOSEXAMPLE"}]}},"public":false,"links":{"clone":[{"href":"ssh://git@repobruegge.in.tum.de:7999/iosexample/example-client.git","name":"ssh"},{"href":"https://ga63cig@repobruegge.in.tum.de/scm/iosexample/example-client.git","name":"http"}],"self":[{"href":"https://repobruegge.in.tum.de/projects/IOSEXAMPLE/repos/example-client/browse"}]}} 3 | """ 4 | -------------------------------------------------------------------------------- /Tests/DangerTests/BitBucketServerTestResources/BitBucketServerUser.swift: -------------------------------------------------------------------------------- 1 | public let BitBucketServerUserJSON = """ 2 | { 3 | "name":"tum-id", 4 | "emailAddress":"user.name@tum.de", 5 | "id":1, 6 | "displayName":"Firstname Lastname", 7 | "active":true, 8 | "slug":"tum-id", 9 | "type":"NORMAL", 10 | "links": { 11 | "self": [ 12 | { 13 | "href":"https://repobruegge.in.tum.de/users/tum-id" 14 | } 15 | ] 16 | } 17 | } 18 | """ 19 | 20 | public let BitBucketServerUserWithoutEmailJSON = """ 21 | { 22 | "name":"tum-id", 23 | "id":1, 24 | "displayName":"Firstname Lastname", 25 | "active":true, 26 | "slug":"tum-id", 27 | "type":"NORMAL", 28 | "links": { 29 | "self": [ 30 | { 31 | "href":"https://repobruegge.in.tum.de/users/tum-id" 32 | } 33 | ] 34 | } 35 | } 36 | """ 37 | -------------------------------------------------------------------------------- /Tests/DangerTests/BitbucketCloudResources/BitbucketCloudCommentUserWithoutAccountIdAndNickname.swift: -------------------------------------------------------------------------------- 1 | public let BitBucketCloudCommentUserWithoutAccountIdAndNickname = """ 2 | { 3 | "links": { 4 | "self": { 5 | "href": "https://api.bitbucket.org/2.0/repositories/Zagolo/danger-kotlin/pullrequests/1/comments/109197958" 6 | }, 7 | "html": { 8 | "href": "https://bitbucket.org/Zagolo/danger-kotlin/pull-requests/1/_/diff#comment-109197958" 9 | } 10 | }, 11 | "deleted": false, 12 | "pullrequest": { 13 | "type": "pullrequest", 14 | "id": 1, 15 | "links": { 16 | "self": { 17 | "href": "https://api.bitbucket.org/2.0/repositories/Zagolo/danger-kotlin/pullrequests/1" 18 | }, 19 | "html": { 20 | "href": "https://bitbucket.org/Zagolo/danger-kotlin/pull-requests/1" 21 | } 22 | }, 23 | "title": "README.md edited online with Bitbucket" 24 | }, 25 | "content": { 26 | "raw": "Test Comment", 27 | "markup": "markdown", 28 | "html": "

Test Comment

", 29 | "type": "rendered" 30 | }, 31 | "created_on": 1603196142, 32 | "user": { 33 | "username": "f-meloni", 34 | "display_name": "Franco Meloni", 35 | "type": "user", 36 | "uuid": "{bd1991e4-a3ed-45b2-be38-acea659650f1}", 37 | "links": { 38 | "self": { 39 | "href": "https://api.bitbucket.org/2.0/users/%7Bbd1991e4-a3ed-45b2-be38-acea659650f1%7D" 40 | }, 41 | "html": { 42 | "href": "https://bitbucket.org/%7Bbd1991e4-a3ed-45b2-be38-acea659650f1%7D/" 43 | }, 44 | "avatar": { 45 | "href": "https://secure.gravatar.com/avatar/3d90e967de2beab6d44cfadbb4976b87?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FFM-1.png" 46 | } 47 | } 48 | }, 49 | "updated_on": 1603196142, 50 | "type": "pullrequest_comment", 51 | "id": 109197958 52 | } 53 | """ 54 | -------------------------------------------------------------------------------- /Tests/DangerTests/BitbucketCloudResources/BitbucketCloudCommit.swift: -------------------------------------------------------------------------------- 1 | public let BitBucketCloudCommitWithoutUser = """ 2 | { 3 | "author":{ 4 | "raw": "Franco Meloni " 5 | }, 6 | "date":1223322, 7 | "hash":"9ab48765728b309d88486a52bb57805fffe20410", 8 | "message": "README.md edited online with Bitbucket" 9 | } 10 | """ 11 | -------------------------------------------------------------------------------- /Tests/DangerTests/DangerDSLTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import DangerFixtures 3 | import XCTest 4 | 5 | final class DangerDSLTests: XCTestCase { 6 | override func tearDown() { 7 | resetDangerResults() 8 | 9 | super.tearDown() 10 | } 11 | 12 | func testFileMapWorksCorrectly() throws { 13 | let fileContent = "123easfsfasd" 14 | let danger = githubWithFilesDSL(created: ["file.swift"], fileMap: ["file.swift": fileContent]) 15 | let file = danger.utils.readFile("file.swift") 16 | XCTAssertEqual(fileContent, file) 17 | } 18 | 19 | func testDangerfileResults() throws { 20 | let danger = githubFixtureDSL 21 | danger.message("Message") 22 | danger.warn("Warning") 23 | danger.fail("Fail") 24 | XCTAssertEqual(danger.messages.count, 1) 25 | XCTAssertEqual(danger.warnings.count, 1) 26 | XCTAssertEqual(danger.fails.count, 1) 27 | } 28 | 29 | func testDangerMetaResults() throws { 30 | let danger = githubFixtureDSL 31 | danger.meta(Meta(runtimeName: "Foo", runtimeHref: "https://foo.com")) 32 | 33 | XCTAssertEqual(danger.meta.runtimeName, "Foo") 34 | XCTAssertEqual(danger.meta.runtimeHref, "https://foo.com") 35 | } 36 | 37 | func testGithubFixtureDSL() throws { 38 | let danger: DangerDSL = githubFixtureDSL 39 | 40 | XCTAssertNil(danger.bitbucketServer) 41 | XCTAssertNotNil(danger.github) 42 | XCTAssertTrue(danger.runningOnGithub) 43 | XCTAssertTrue(danger.supportsSuggestions) 44 | XCTAssertNotNil(danger.git) 45 | XCTAssertEqual(danger.github.api.configuration.accessToken, "7bd263f8e4becaa3d29b25d534fe6d5f3b555ccf".base64Encoded) 46 | } 47 | 48 | func testItParsesCorrectlyTheDangerDSLWhenThePRIsOnGithubEnterprise() throws { 49 | let danger: DangerDSL = githubEnterpriseFixtureDSL 50 | 51 | XCTAssertNil(danger.bitbucketServer) 52 | XCTAssertNotNil(danger.github) 53 | XCTAssertTrue(danger.runningOnGithub) 54 | XCTAssertTrue(danger.supportsSuggestions) 55 | XCTAssertNotNil(danger.git) 56 | XCTAssertEqual(danger.github.api.configuration.accessToken, "7bd263f8e4becaa3d29b25d534fe6d5f3b555ccf".base64Encoded) 57 | XCTAssertEqual(danger.github.api.configuration.apiEndpoint, "https://base.url.io") 58 | } 59 | 60 | func testItParsesCorrectlyTheDangerDSLWhenThePRIsOnBitBucketServer() throws { 61 | let danger: DangerDSL = bitbucketFixtureDSL 62 | 63 | XCTAssertNotNil(danger.bitbucketServer) 64 | XCTAssertNil(danger.github) 65 | XCTAssertFalse(danger.runningOnGithub) 66 | XCTAssertFalse(danger.supportsSuggestions) 67 | XCTAssertNotNil(danger.git) 68 | } 69 | } 70 | 71 | private extension String { 72 | var base64Encoded: String? { 73 | data(using: .utf8)?.base64EncodedString() 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Tests/DangerTests/DangerUtilsLineSearchTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import DangerFixtures 3 | import XCTest 4 | 5 | final class DangerUtilsLineSearchTests: XCTestCase { 6 | var fileContent: String { 7 | """ 8 | not here 9 | no 10 | match 11 | not here 12 | no 13 | match 14 | """.replacingOccurrences(of: "\n", with: "\\n") 15 | } 16 | 17 | func testItReturnsAnEmptyArrayIfNoResultsAreFound() throws { 18 | let danger = githubWithFilesDSL(created: ["file.swift"], fileMap: ["file.swift": fileContent]) 19 | 20 | XCTAssertTrue(danger.utils.lines(for: "No results", inFile: "file.swift").isEmpty) 21 | } 22 | 23 | func testItReturnsTheCorrectResultsIfTheSearchedStringIsPresent() throws { 24 | let danger = githubWithFilesDSL(created: ["file.swift"], fileMap: ["file.swift": fileContent]) 25 | 26 | XCTAssert(danger.utils.lines(for: "match", inFile: "file.swift") == [3, 6]) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Tests/DangerTests/DateFormatterExtensionTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import XCTest 3 | 4 | final class DateFormatterExtensionTests: XCTestCase { 5 | private var dateFormatter: DateFormatter { 6 | DateFormatter.defaultDateFormatter 7 | } 8 | 9 | func test_DateFormatter_dateFromString() { 10 | var dateComponents = DateComponents() 11 | dateComponents.year = 2020 12 | dateComponents.month = 6 13 | dateComponents.day = 24 14 | 15 | dateComponents.hour = 23 16 | dateComponents.minute = 13 17 | dateComponents.second = 8 18 | dateComponents.timeZone = TimeZone(abbreviation: "GMT") 19 | dateComponents.calendar = Calendar(identifier: .gregorian) 20 | 21 | guard let testDate = dateFormatter.date(from: "2020-06-24T23:13:08Z"), 22 | let correctDate = dateComponents.date 23 | else { 24 | XCTFail("Could not generate date") 25 | return 26 | } 27 | 28 | XCTAssertEqual(testDate, correctDate) 29 | } 30 | 31 | func test_DateFormatter_nilFromInvalidString() { 32 | XCTAssertNil(dateFormatter.date(from: "2020-0d-24T23:13:08Z")) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Tests/DangerTests/DateFormatterHandlerTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import Foundation 3 | import XCTest 4 | 5 | final class DateFormatterHandlerTests: XCTestCase { 6 | func testRegularParseSuccess() throws { 7 | let decoder = JSONDecoder() 8 | decoder.dateDecodingStrategy = .custom(DateFormatter.dateFormatterHandler) 9 | 10 | let json = """ 11 | { "date": "2019-04-10T21:57:45.000Z" } 12 | """ 13 | let data = Data(json.utf8) 14 | 15 | let dummy = try decoder.decode(DummyModel.self, from: data) 16 | XCTAssertEqual(dummy.date, Date(timeIntervalSince1970: 1_554_933_465.000)) 17 | } 18 | 19 | func testOnlyDateParseSuccess() throws { 20 | let decoder = JSONDecoder() 21 | decoder.dateDecodingStrategy = .custom(DateFormatter.dateFormatterHandler) 22 | 23 | let json = """ 24 | { "date": "2019-04-10" } 25 | """ 26 | let data = Data(json.utf8) 27 | 28 | let dummy = try decoder.decode(DummyModel.self, from: data) 29 | XCTAssertEqual(dummy.date, Date(timeIntervalSince1970: 1_554_854_400.000)) 30 | } 31 | 32 | func testUnexpectedDateThrows() { 33 | let decoder = JSONDecoder() 34 | decoder.dateDecodingStrategy = .custom(DateFormatter.dateFormatterHandler) 35 | 36 | let json = """ 37 | { "date": "2019*04*10" } 38 | """ 39 | let data = Data(json.utf8) 40 | 41 | XCTAssertThrowsError(try decoder.decode(DummyModel.self, from: data)) { error in 42 | XCTAssertEqual(error.localizedDescription, "Format Invalid with path \"date\", date string: \"2019*04*10\"") 43 | } 44 | } 45 | 46 | // MARK: Test Helpers 47 | 48 | private struct DummyModel: Decodable { 49 | let date: Date 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Tests/DangerTests/DefaultDateFormatterTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import Foundation 3 | import XCTest 4 | 5 | final class DefaultDateFormatterTests: XCTestCase { 6 | var formatter: DateFormatter { 7 | DateFormatter.defaultDateFormatter 8 | } 9 | 10 | func testParsesDateWithMilliseconds() { 11 | let testDateString = "2019-04-10T21:56:43.500Z" 12 | 13 | XCTAssertEqual(formatter.date(from: testDateString), Date(timeIntervalSince1970: 1_554_933_403.5)) 14 | } 15 | 16 | func testParsesDateWithoutMilliseconds() { 17 | let testDateString = "2019-04-10T21:56:43Z" 18 | 19 | XCTAssertEqual(formatter.date(from: testDateString), Date(timeIntervalSince1970: 1_554_933_403)) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Tests/DangerTests/FileTypeTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import XCTest 3 | 4 | final class FileTypeTests: XCTestCase { 5 | func test_extension_matchesRawValue() { 6 | for type in FileType.allCases { 7 | XCTAssertEqual(type.extension, type.rawValue) 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Tests/DangerTests/GitHubTestResources/GitHubBot.swift: -------------------------------------------------------------------------------- 1 | public let GitHubBotJSON = """ 2 | { 3 | "login": "dependabot-preview[bot]", 4 | "id": 27856297, 5 | "node_id": "MDM6Qm90Mjc4NTYyOTc=", 6 | "avatar_url": "https://avatars3.githubusercontent.com/in/2141?v=4", 7 | "gravatar_id": "", 8 | "url": "https://api.github.com/users/dependabot-preview%5Bbot%5D", 9 | "html_url": "https://github.com/apps/dependabot-preview", 10 | "followers_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/followers", 11 | "following_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/following{/other_user}", 12 | "gists_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/gists{/gist_id}", 13 | "starred_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/starred{/owner}{/repo}", 14 | "subscriptions_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/subscriptions", 15 | "organizations_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/orgs", 16 | "repos_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/repos", 17 | "events_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/events{/privacy}", 18 | "received_events_url": "https://api.github.com/users/dependabot-preview%5Bbot%5D/received_events", 19 | "type": "Bot", 20 | "site_admin": false 21 | } 22 | """ 23 | -------------------------------------------------------------------------------- /Tests/DangerTests/GitHubTestResources/GitHubTeam.swift: -------------------------------------------------------------------------------- 1 | public let GitHubTeamJSON = """ 2 | 3 | { 4 | "id": 1, 5 | "url": "https://api.github.com/teams/1", 6 | "name": "Justice League", 7 | "slug": "justice-league", 8 | "description": "A great team.", 9 | "privacy": "closed", 10 | "permission": "admin", 11 | "members_url": "https://api.github.com/teams/1/members{/member}", 12 | "repositories_url": "https://api.github.com/teams/1/repos", 13 | "parent": null, 14 | "members_count": 3, 15 | "repos_count": 10, 16 | "created_at": "2017-07-14T16:53:42Z", 17 | "updated_at": "2017-08-17T12:37:15Z", 18 | "organization": { 19 | "login": "github", 20 | "id": 1, 21 | "url": "https://api.github.com/orgs/github", 22 | "repos_url": "https://api.github.com/orgs/github/repos", 23 | "events_url": "https://api.github.com/orgs/github/events", 24 | "hooks_url": "https://api.github.com/orgs/github/hooks", 25 | "issues_url": "https://api.github.com/orgs/github/issues", 26 | "members_url": "https://api.github.com/orgs/github/members{/member}", 27 | "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", 28 | "avatar_url": "https://github.com/images/error/octocat_happy.gif", 29 | "description": "A great organization" 30 | } 31 | } 32 | 33 | """ 34 | -------------------------------------------------------------------------------- /Tests/DangerTests/GitHubTestResources/GitHubUser.swift: -------------------------------------------------------------------------------- 1 | public let GitHubUserJSON = """ 2 | 3 | {"login":"yhkaplan","id":25879490,"avatar_url":"https://avatars0.githubusercontent.com/u/25879490?v=4","gravatar_id":"","url":"https://api.github.com/users/yhkaplan","html_url":"https://github.com/yhkaplan","followers_url":"https://api.github.com/users/yhkaplan/followers","following_url":"https://api.github.com/users/yhkaplan/following{/other_user}","gists_url":"https://api.github.com/users/yhkaplan/gists{/gist_id}","starred_url":"https://api.github.com/users/yhkaplan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yhkaplan/subscriptions","organizations_url":"https://api.github.com/users/yhkaplan/orgs","repos_url":"https://api.github.com/users/yhkaplan/repos","events_url":"https://api.github.com/users/yhkaplan/events{/privacy}","received_events_url":"https://api.github.com/users/yhkaplan/received_events","type":"User","site_admin":false,"name":null,"company":null,"blog":"","location":"Tokyo","email":null,"hireable":null,"bio":null,"public_repos":13,"public_gists":0,"followers":1,"following":37,"created_at":"2017-02-19T11:30:07Z","updated_at":"2018-02-20T09:58:51Z"} 4 | 5 | """ 6 | -------------------------------------------------------------------------------- /Tests/DangerTests/GitLabMilestoneTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import DangerFixtures 3 | import XCTest 4 | 5 | final class GitLabMilestoneTests: XCTestCase { 6 | func testParseGroupMilestone() throws { 7 | let jsonString = DSLGitLabGroupMilestoneJSON 8 | let data = Data(jsonString.utf8) 9 | 10 | let milestone = try jsonDecoder.decode(GitLab.MergeRequest.Milestone.self, from: data) 11 | XCTAssertTrue(milestone.parent.isGroup) 12 | XCTAssertEqual(milestone.parent.id, 9_449_452) 13 | } 14 | 15 | func testParseProjectMilestone() throws { 16 | let jsonString = DSLGitLabProjectMilestoneJSON 17 | let data = Data(jsonString.utf8) 18 | 19 | let milestone = try jsonDecoder.decode(GitLab.MergeRequest.Milestone.self, from: data) 20 | XCTAssertTrue(milestone.parent.isProject) 21 | XCTAssertEqual(milestone.parent.id, 21_265_694) 22 | } 23 | 24 | func testParseMilestoneFailure() throws { 25 | let jsonString = "{}" 26 | let data = Data(jsonString.utf8) 27 | 28 | XCTAssertThrowsError( 29 | try jsonDecoder.decode( 30 | GitLab.MergeRequest.Milestone.self, 31 | from: data 32 | ) 33 | ) 34 | } 35 | 36 | private var jsonDecoder: JSONDecoder { 37 | let decoder = JSONDecoder() 38 | decoder.dateDecodingStrategy = .custom(DateFormatter.dateFormatterHandler) 39 | return decoder 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Tests/DangerTests/NSRegularExpressionExtensionsTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import XCTest 3 | 4 | final class NSRegularExpressionExtensionsTests: XCTestCase { 5 | var string: String { 6 | "Dogs and cats were wearing hats" 7 | } 8 | 9 | func test_firstMatchingString_passingRegex() { 10 | let pattern = "(cats|hats)$" 11 | let expectedMatch = "hats" 12 | 13 | guard 14 | let expression = try? NSRegularExpression(pattern: pattern), 15 | let testMatch = expression.firstMatchingString(in: string) 16 | else { 17 | XCTFail("Invalid regular expression") 18 | return 19 | } 20 | 21 | XCTAssertEqual(testMatch, expectedMatch) 22 | } 23 | 24 | func test_firstMatchingString_failingRegex() { 25 | let pattern = "^(cats|hats)" 26 | 27 | guard let expression = try? NSRegularExpression(pattern: pattern) else { 28 | XCTFail("Invalid regular expression") 29 | return 30 | } 31 | 32 | let testMatch = expression.firstMatchingString(in: string) 33 | 34 | XCTAssertNil(testMatch) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Tests/DangerTests/OnlyDateDateFormatterTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import Foundation 3 | import XCTest 4 | 5 | final class OnlyDateDateFormatterTests: XCTestCase { 6 | var formatter: DateFormatter { 7 | DateFormatter.onlyDateDateFormatter 8 | } 9 | 10 | func testParsesDate() { 11 | let testDateString = "2019-04-10" 12 | 13 | XCTAssertEqual(formatter.date(from: testDateString), Date(timeIntervalSince1970: 1_554_854_400.0)) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Tests/DangerTests/SwiftLint/FakeCurrentPathProvider.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | 3 | final class FakeCurrentPathProvider: CurrentPathProvider { 4 | var currentPath: String = "" 5 | } 6 | -------------------------------------------------------------------------------- /Tests/DangerTests/SwiftLint/FakeShellExecutor.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import DangerShellExecutor 3 | 4 | final class FakeShellExecutor: ShellExecuting { 5 | typealias Invocation = (command: String, arguments: [String], environmentVariables: [String: String], outputFile: String?) 6 | 7 | var invocations = [Invocation]() /// All of the invocations received by this instance. 8 | var output = "[]" /// This is returned by `execute` as the process' standard output. We default to an empty JSON array. 9 | 10 | func execute(_ command: String, arguments: [String], environmentVariables: [String: String], outputFile: String?) -> String { 11 | invocations.append((command: command, arguments: arguments, environmentVariables: environmentVariables, outputFile: outputFile)) 12 | return output 13 | } 14 | 15 | func spawn(_ command: String, arguments: [String], environmentVariables: [String: String], outputFile: String?) throws -> String { 16 | invocations.append((command: command, arguments: arguments, environmentVariables: environmentVariables, outputFile: outputFile)) 17 | return output 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Tests/DangerTests/SwiftLint/SwiftlintDefaultPathTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import XCTest 3 | 4 | final class SwiftlintDefaultPathTests: XCTestCase { 5 | var package: String { 6 | "testPackage.swift" 7 | } 8 | 9 | override func tearDown() { 10 | try? FileManager.default.removeItem(atPath: package) 11 | super.tearDown() 12 | } 13 | 14 | func testItReturnsTheSPMCommandIfThePackageContainsTheSwiftlintDependency() { 15 | givenAFakePackage(hasSwiftlintDep: true) 16 | 17 | XCTAssertEqual(SwiftLint.swiftlintDefaultPath(packagePath: package), "swift run swiftlint") 18 | } 19 | 20 | func testItReturnsTheSwiftlintCLICommandIfThePackageContainsTheSwiftlintDependency() { 21 | givenAFakePackage(hasSwiftlintDep: false) 22 | 23 | XCTAssertEqual(SwiftLint.swiftlintDefaultPath(packagePath: package), "swiftlint") 24 | } 25 | 26 | private func givenAFakePackage(hasSwiftlintDep: Bool) { 27 | try? """ 28 | // swift-tools-version:4.2 29 | 30 | import PackageDescription 31 | 32 | // Version number can be found in Source/Danger/Danger.swift 33 | 34 | let package = Package( 35 | name: "danger-swift", 36 | products: [ 37 | .library(name: "Danger", type: .dynamic, targets: ["Danger"]), 38 | .library(name: "DangerFixtures", type: .dynamic, targets: ["DangerFixtures"]), 39 | .executable(name: "danger-swift", targets: ["Runner"]), 40 | ], 41 | dependencies: [ 42 | .package(url: "https://github.com/f-meloni/Logger", from: "0.1.0"), 43 | .package(url: "https://github.com/JohnSundell/Marathon", from: "3.1.0"), 44 | .package(url: "https://github.com/JohnSundell/ShellOut", from: "2.1.0"), 45 | .package(url: "https://github.com/nerdishbynature/octokit.swift", from: "0.9.0"), 46 | // Danger Plugins 47 | // Dev dependencies 48 | .package(url: "https://github.com/eneko/SourceDocs", from: "0.5.1"), // dev 49 | .package(url: "https://github.com/orta/Komondor", from: "1.0.0"), // dev 50 | .package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.35.8"), // dev 51 | \(hasSwiftlintDep ? ".package(url: \"https://github.com/Realm/SwiftLint\", from: \"0.28.1\")" : "") 52 | .package(url: "https://github.com/f-meloni/Rocket", from: "0.4.0"), // dev 53 | ], 54 | targets: [ 55 | .target(name: "Danger", dependencies: ["ShellOut", "OctoKit", "Logger"]), 56 | .target(name: "RunnerLib", dependencies: ["Logger", "ShellOut"]), 57 | .target(name: "Runner", dependencies: ["RunnerLib", "MarathonCore", "Logger"]), 58 | .target(name: "DangerFixtures", dependencies: ["Danger"]), 59 | .testTarget(name: "DangerTests", dependencies: ["Danger", "DangerFixtures"]), 60 | .testTarget(name: "RunnerLibTests", dependencies: ["RunnerLib"]), 61 | ]) 62 | """.write(toFile: package, atomically: false, encoding: .utf8) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Tests/DangerTests/SwiftLint/SwiftlintReportDeleterTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import XCTest 3 | 4 | final class SwiftlintReportDeleterTests: XCTestCase { 5 | func testCallsRemoveItemOnFileManager() throws { 6 | let spyFileManager = SpyFileManager() 7 | let deleter = SwiftlintReportDeleter(fileManager: spyFileManager) 8 | let testPath = "testPath" 9 | 10 | try deleter.deleteReport(atPath: testPath) 11 | 12 | XCTAssertEqual(spyFileManager.receivedPath, testPath) 13 | } 14 | } 15 | 16 | private class SpyFileManager: FileManager { 17 | private(set) var receivedPath: String? 18 | 19 | override func removeItem(atPath path: String) throws { 20 | receivedPath = path 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Tests/DangerTests/SwiftLint/ViolationTests.swift: -------------------------------------------------------------------------------- 1 | @testable import Danger 2 | import XCTest 3 | 4 | final class ViolationTests: XCTestCase { 5 | func testDecoding() throws { 6 | let json = """ 7 | { 8 | "rule_id" : "opening_brace", 9 | "reason" : "Opening braces should be preceded by a single space and on the same line as the declaration.", 10 | "character" : 39, 11 | "file" : "/Users/ash/bin/Harvey/Sources/Harvey/Harvey.swift", 12 | "severity" : "Warning", 13 | "type" : "Opening Brace Spacing", 14 | "line" : 8 15 | } 16 | """ 17 | let subject = try JSONDecoder().decode(SwiftLintViolation.self, from: Data(json.utf8)) 18 | XCTAssertEqual(subject.ruleID, "opening_brace") 19 | XCTAssertEqual(subject.reason, "Opening braces should be preceded by a single space and on the same line as the declaration.") 20 | XCTAssertEqual(subject.line, 8) 21 | XCTAssertEqual(subject.file, "/Users/ash/bin/Harvey/Sources/Harvey/Harvey.swift") 22 | XCTAssertEqual(subject.severity, .warning) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/CliParserTests.swift: -------------------------------------------------------------------------------- 1 | @testable import RunnerLib 2 | import XCTest 3 | 4 | final class CliParserTests: XCTestCase { 5 | private var parser: CliArgsParser! 6 | 7 | override func setUp() { 8 | super.setUp() 9 | parser = CliArgsParser() 10 | } 11 | 12 | override func tearDown() { 13 | parser = nil 14 | super.tearDown() 15 | } 16 | 17 | func testItReturnsTheCliArgsIfTheJSONIsCorrect() { 18 | let cli = parser.parseCli(fromData: Data(correctJSON.utf8)) 19 | 20 | XCTAssertEqual(cli?.id, "testId") 21 | XCTAssertEqual(cli?.base, "testBase") 22 | XCTAssertEqual(cli?.verbose, "testVerbose") 23 | XCTAssertEqual(cli?.externalCiProvider, "testExternalCiProvider") 24 | XCTAssertEqual(cli?.textOnly, "testTextOnly") 25 | XCTAssertEqual(cli?.dangerfile, "testDangerfile") 26 | } 27 | 28 | func testItReturnsTheCliArgsIfTheJSONIsCorrectButDoesntContainAllTheFields() { 29 | let cli = parser.parseCli(fromData: Data(correctJSONWithOnlyDangerfile.utf8)) 30 | 31 | XCTAssertNil(cli?.id) 32 | XCTAssertNil(cli?.base) 33 | XCTAssertNil(cli?.verbose) 34 | XCTAssertNil(cli?.externalCiProvider) 35 | XCTAssertNil(cli?.textOnly) 36 | XCTAssertEqual(cli?.dangerfile, "testDangerfile") 37 | } 38 | 39 | func testItReturnsNilIfTheJSONDoesntContainCliArgs() { 40 | let cli = parser.parseCli(fromData: Data(jsonWithoutCliArgs.utf8)) 41 | 42 | XCTAssertNil(cli) 43 | } 44 | } 45 | 46 | extension CliParserTests { 47 | private var correctJSON: String { 48 | """ 49 | { 50 | "danger": { 51 | "settings": { 52 | "cliArgs": { 53 | "id": "testId", 54 | "base": "testBase", 55 | "verbose": "testVerbose", 56 | "externalCiProvider": "testExternalCiProvider", 57 | "textOnly": "testTextOnly", 58 | "dangerfile": "testDangerfile" 59 | } 60 | } 61 | } 62 | } 63 | """ 64 | } 65 | 66 | private var correctJSONWithOnlyDangerfile: String { 67 | """ 68 | { 69 | "danger": { 70 | "settings": { 71 | "cliArgs": { 72 | "dangerfile": "testDangerfile" 73 | } 74 | } 75 | } 76 | } 77 | """ 78 | } 79 | 80 | private var jsonWithoutCliArgs: String { 81 | """ 82 | { 83 | "danger": { 84 | "settings": { 85 | } 86 | } 87 | } 88 | """ 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/DangerCommandTests.swift: -------------------------------------------------------------------------------- 1 | @testable import RunnerLib 2 | import XCTest 3 | 4 | final class DangerCommandTests: XCTestCase { 5 | func testItReturnsTheCorrectCommandsListText() { 6 | let expectedResult = DangerCommand.allCases.reduce("") { result, command -> String in 7 | result + command.rawValue + "\t" + command.commandDescription + "\n" 8 | } 9 | 10 | XCTAssertEqual(DangerCommand.commandsListText, expectedResult) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/DangerJSVersionFinderTests.swift: -------------------------------------------------------------------------------- 1 | @testable import RunnerLib 2 | import XCTest 3 | 4 | final class DangerJSVersionFinderTests: XCTestCase { 5 | func testItSendsTheCorrectCommandAndReturnsTheCorrectResult() throws { 6 | let executor = MockedExecutor() 7 | executor.result = { _ in "1.0.0" } 8 | 9 | let dangerJSPath = "/test/danger" 10 | 11 | let version = DangerJSVersionFinder.findDangerJSVersion(dangerJSPath: dangerJSPath, executor: executor) 12 | 13 | XCTAssertEqual(executor.receivedCommands, [dangerJSPath + " --version"]) 14 | XCTAssertEqual(version, "1.0.0") 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/DangerfilePathFinderTests.swift: -------------------------------------------------------------------------------- 1 | @testable import RunnerLib 2 | import XCTest 3 | 4 | final class DangerfilePathFinderTests: XCTestCase { 5 | func testItReturnsTheCorrectPathIfTheArgumentsContainsTheDangerfileArg() { 6 | let arguments = ["--id", "danger", "--dangerfile", "Dangertest.swift"] 7 | 8 | XCTAssertEqual(DangerfilePathFinder.dangerfilePath(fromArguments: arguments), "Dangertest.swift") 9 | } 10 | 11 | func testItReturnsNilIfTheArgumentsDoesntContainTheDangerfileArg() { 12 | let arguments = ["--id", "danger"] 13 | 14 | XCTAssertEqual(DangerfilePathFinder.dangerfilePath(fromArguments: arguments), nil) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/GetDangerJSPathTests.swift: -------------------------------------------------------------------------------- 1 | import Logger 2 | @testable import RunnerLib 3 | import XCTest 4 | 5 | final class GetDangerJSPathTests: XCTestCase { 6 | private var logger: Logger { 7 | Logger(isVerbose: false, isSilent: false, printer: SpyPrinter()) 8 | } 9 | 10 | func testItUsesDangerJSPathOptionIfPresent() throws { 11 | let expectedResult = "/franco/test/danger-js" 12 | let path = try getDangerCommandPath(logger: logger, args: ["test", "--danger-js-path", expectedResult]) 13 | XCTAssertEqual(path, expectedResult) 14 | } 15 | 16 | func testItSearchesForDangerJSIfDangerJSPathOptionIsNotPresent() throws { 17 | let executor = MockedExecutor() 18 | executor.result = { _ in "/usr/test/danger-js" } 19 | 20 | let path = try getDangerCommandPath(logger: logger, args: [], shellOutExecutor: executor) 21 | XCTAssertEqual(executor.receivedCommands, ["command -v danger-js"]) 22 | XCTAssertEqual(path, "/usr/test/danger") 23 | } 24 | 25 | func testItSearchesForDangerIfTheDangerPathOptionIsNotPresentAndDangerJSIsNotFound() throws { 26 | let executor = MockedExecutor() 27 | let expectedResult = "/usr/test/danger" 28 | executor.result = { command in 29 | if command.hasSuffix("danger-js") { 30 | return "" 31 | } else { 32 | return expectedResult 33 | } 34 | } 35 | 36 | let path = try getDangerCommandPath(logger: logger, args: [], shellOutExecutor: executor) 37 | XCTAssertEqual(executor.receivedCommands, ["command -v danger-js", "command -v danger"]) 38 | XCTAssertEqual(path, expectedResult) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/HelpMessagePresenterTests.swift: -------------------------------------------------------------------------------- 1 | import Logger 2 | import RunnerLib 3 | import XCTest 4 | 5 | final class HelpMessagePresenterTests: XCTestCase { 6 | func testIsShowsTheCommandListWhenThereIsNoCommand() { 7 | let spyPrinter = SpyPrinter() 8 | HelpMessagePresenter.showHelpMessage(command: nil, logger: Logger(isVerbose: false, isSilent: false, printer: spyPrinter)) 9 | 10 | XCTAssert(spyPrinter.printedMessages.contains(DangerCommand.commandsListText)) 11 | } 12 | } 13 | 14 | final class SpyPrinter: Printing { 15 | private(set) var printedMessages: [String] = [] 16 | 17 | func print(_ message: String, terminator _: String) { 18 | printedMessages.append(message) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/ImportsFinderTests.swift: -------------------------------------------------------------------------------- 1 | import RunnerLib 2 | import XCTest 3 | 4 | final class ImportsFinderTests: XCTestCase { 5 | var importsFinder: ImportsFinder! 6 | 7 | override func setUp() { 8 | super.setUp() 9 | importsFinder = ImportsFinder() 10 | } 11 | 12 | override func tearDown() { 13 | importsFinder = nil 14 | super.tearDown() 15 | } 16 | 17 | func testItRetunsTheCorrectFilePathsWhenThePassedStringContainsImports() { 18 | checkReturnsTheCorrectFilePaths(string: stringWithImports, expectedResult: ["File1", "File2"]) 19 | } 20 | 21 | func testItRetunsAnEmptyListWhenThePassedStringDoesntContainImports() { 22 | checkReturnsTheCorrectFilePaths(string: stringWithoutImports, expectedResult: []) 23 | } 24 | 25 | func testResolveImportPath() { 26 | let dangerfilePath = "/path/to/danger/swift/Dangerfile.swift" 27 | XCTAssertEqual(importsFinder.resolveImportPath("DangerfileExtensions/ChangelogCheck.swift", relativeTo: dangerfilePath), "/path/to/danger/swift/DangerfileExtensions/ChangelogCheck.swift") 28 | 29 | XCTAssertEqual(importsFinder.resolveImportPath("SomeFile", relativeTo: dangerfilePath), "/path/to/danger/swift/SomeFile") 30 | } 31 | } 32 | 33 | extension ImportsFinderTests { 34 | private var stringWithImports: String { 35 | """ 36 | // fileImport: File1 37 | 38 | text text 39 | 40 | // fileImport: File2 41 | """ 42 | } 43 | 44 | private var stringWithoutImports: String { 45 | """ 46 | // comment 47 | 48 | text text 49 | 50 | more text 51 | """ 52 | } 53 | 54 | private func checkReturnsTheCorrectFilePaths(string: String, expectedResult: [String]) { 55 | let files = importsFinder.findImports(inString: string) 56 | XCTAssertEqual(files, expectedResult) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/MockedExecutor.swift: -------------------------------------------------------------------------------- 1 | import DangerShellExecutor 2 | import RunnerLib 3 | 4 | final class MockedExecutor: ShellExecuting { 5 | var receivedCommands: [String] = [] 6 | var result: (String) -> String = { _ in "" } 7 | 8 | func execute(_ command: String, arguments: [String], environmentVariables _: [String: String], outputFile _: String?) -> String { 9 | let receivedCommand = makeReceivedCommand(command, arguments: arguments) 10 | receivedCommands.append(receivedCommand) 11 | return result(receivedCommand) 12 | } 13 | 14 | func spawn(_ command: String, arguments: [String], environmentVariables _: [String: String], outputFile _: String?) throws -> String { 15 | let receivedCommand = makeReceivedCommand(command, arguments: arguments) 16 | receivedCommands.append(receivedCommand) 17 | return result(receivedCommand) 18 | } 19 | 20 | private func makeReceivedCommand(_ command: String, arguments: [String]) -> String { 21 | command + (arguments.isEmpty ? "" : " " + arguments.joined(separator: " ")) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/StringPathExtensionTests.swift: -------------------------------------------------------------------------------- 1 | @testable import RunnerLib 2 | import XCTest 3 | 4 | public class StringPathExtensionTests: XCTestCase { 5 | func testAppendingPathWhenPathEndsWithSlash() { 6 | XCTAssertEqual("/usr/".appendingPath("f-meloni"), "/usr/f-meloni") 7 | } 8 | 9 | func testAppendingPathWhenPathEndsWithoutSlash() { 10 | XCTAssertEqual("/usr".appendingPath("f-meloni"), "/usr/f-meloni") 11 | } 12 | 13 | func testRemovingLastPathComponentWhenPathHasOnlyOneComponent() { 14 | XCTAssertEqual("usr".removingLastPathComponent(), "usr") 15 | } 16 | 17 | func testRemovingLastPathComponentWhenPathHasOnlyOneComponentAndStartsWithSlash() { 18 | XCTAssertEqual("/usr".removingLastPathComponent(), "/usr") 19 | } 20 | 21 | func testRemovingLastPathComponentWhenPathHasMoreThanOneComponentAndStartsWithSlash() { 22 | XCTAssertEqual("usr/f-meloni".removingLastPathComponent(), "usr") 23 | } 24 | 25 | func testRemovingLastPathComponentWhenPathHasMoreThanOneComponent() { 26 | XCTAssertEqual("/usr/f-meloni".removingLastPathComponent(), "/usr") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Tests/RunnerLibTests/__Snapshots__/DangerFileGeneratorTests/testItGeneratesTheCorrectFileWhenOneOfTheImportedFilesIsMissing.1.txt: -------------------------------------------------------------------------------- 1 | import Danger 2 | 3 | file2Content ⚠️ 4 | 5 | // fileImport: GeneratedTestFile3.swift 6 | 7 | let danger = Danger() 8 | 9 | file1Content 👍🏻 10 | secondLine 11 | message("Text") 12 | message("Another Text") -------------------------------------------------------------------------------- /Tests/RunnerLibTests/__Snapshots__/DangerFileGeneratorTests/testItGeneratesTheCorrectFileWhenThereAreNoImports.1.txt: -------------------------------------------------------------------------------- 1 | import Danger 2 | 3 | let danger = Danger() 4 | 5 | message("Text") 6 | message("Another Text") -------------------------------------------------------------------------------- /Tests/RunnerLibTests/__Snapshots__/DangerFileGeneratorTests/testItGeneratesTheCorrectFileWhenThereIsASingleImport.1.txt: -------------------------------------------------------------------------------- 1 | import Danger 2 | 3 | let danger = Danger() 4 | 5 | file1Content 👍🏻 6 | secondLine 7 | message("Text") 8 | message("Another Text") -------------------------------------------------------------------------------- /Tests/RunnerLibTests/__Snapshots__/DangerFileGeneratorTests/testItGeneratesTheCorrectFileWhenThereIsAreImportsWithIndent.1.txt: -------------------------------------------------------------------------------- 1 | import Danger 2 | import Foundation 3 | 4 | let danger = Danger() 5 | 6 | if flag { 7 | 8 | file2Content ⚠️ 9 | } else { 10 | 11 | file3Content 👩‍👩‍👦‍👦 12 | secondLine 13 | really really really really really really really really really really really really really really really really really really really really really really long text 14 | } 15 | message("Text") 16 | message("Another Text") -------------------------------------------------------------------------------- /Tests/RunnerLibTests/__Snapshots__/DangerFileGeneratorTests/testItGeneratesTheCorrectFileWhenThereIsAreMultipleImports.1.txt: -------------------------------------------------------------------------------- 1 | import Danger 2 | import Foundation 3 | 4 | file2Content ⚠️ 5 | 6 | 7 | file3Content 👩‍👩‍👦‍👦 8 | secondLine 9 | really really really really really really really really really really really really really really really really really really really really really really long text 10 | 11 | let danger = Danger() 12 | 13 | file1Content 👍🏻 14 | secondLine 15 | message("Text") 16 | message("Another Text") -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "prettier": { 3 | "printWidth": 120, 4 | "semi": false, 5 | "singleQuote": false, 6 | "trailingComma": "es5", 7 | "bracketSpacing": true, 8 | "proseWrap": "always" 9 | }, 10 | "dependencies": { 11 | "prettier": "^1.15.3" 12 | } 13 | } 14 | --------------------------------------------------------------------------------