diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 166746c09..4ffa70a2f 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,3 +1,6 @@ +# *.fsx,*.fs: formatting F# files using fantomless +df5cfb143c4efe73806ead91e5cddf4e133be0a8 + # commitlint.config: split helper funcs and plugins 3008d6578aa484ae776b29c9246dca4eeae3418a diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 28af6800c..3a257b1dc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -3,99 +3,8 @@ name: CI on: [push, pull_request] jobs: - build: - name: Build - runs-on: ubuntu-22.04 - container: - image: "ubuntu:22.04" - steps: - - uses: actions/checkout@v2 - - name: Install required dependencies - run: | - apt update - apt install -y sudo - sudo apt install -y git - # workaround for https://github.com/actions/runner/issues/2033 - - name: ownership workaround - run: git config --global --add safe.directory '*' - - name: Install dotnet sdk - run: sudo apt install -y dotnet6 - - name: Compile the conventions solution - run: dotnet build --configuration Release conventions.sln - - name: Compile F# scripts - run: dotnet fsi scripts/compileFSharpScripts.fsx - - file-conventions-tests: - name: Run FileConventions-lib unit tests - needs: build - runs-on: ubuntu-22.04 - container: - image: "ubuntu:22.04" - steps: - - uses: actions/checkout@v2 - - name: Install required dependencies - run: | - apt update - apt install --yes sudo - - # We need to install curl otherwise we get these errors in the CI: - # Unable to load the service index for source https://api.nuget.org/v3/index.json. - # The SSL connection could not be established, see inner exception. - # The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot - sudo apt install --yes curl - - - name: Setup .NET - run: apt install -y dotnet6 - - name: Run tests to validate F# scripts - run: dotnet test src/FileConventions.Test/FileConventions.Test.fsproj - - commitlint-plugins-tests: - name: Run commitlint-related tests - needs: build - runs-on: ubuntu-22.04 - container: - image: "ubuntu:22.04" - steps: - - uses: actions/checkout@v2 - - name: Install required dependencies - run: | - apt update - apt install --yes sudo - sudo apt install --yes git - - sudo apt install --yes curl - # can't install ubuntu's default nodejs version because we would get this error: - # error @jest/core@29.4.1: The engine "node" is incompatible with this module. Expected version "^14.15.0 || ^16.10.0 || >=18.0.0". Got "12.22.9" - curl --show-error --location https://deb.nodesource.com/setup_14.x | sudo --preserve-env bash - - sudo DEBIAN_FRONTEND=noninteractive apt install --yes nodejs - - name: Print versions - run: | - git --version - node --version - npm --version - npx commitlint --version - - name: Install yarn - run: | - npm install --global yarn - yarn add --dev jest typescript ts-jest @types/jest - - name: Install commitlint - run: | - npm install conventional-changelog-conventionalcommits - npm install commitlint@latest - - name: Print versions - run: | - git --version - node --version - npm --version - npx commitlint --version - - name: Run tests to validate our plugins - run: yarn jest - sanity-check: name: Sanity check - needs: - - file-conventions-tests - - commitlint-plugins-tests runs-on: ubuntu-22.04 container: image: "ubuntu:22.04" @@ -129,37 +38,9 @@ jobs: --to ${{ github.event.pull_request.head.sha }} - name: Install dotnet sdk run: sudo apt install --yes dotnet6 - - name: Check all files end with EOL - run: dotnet fsi scripts/eofConvention.fsx - - name: Check all .fsx scripts have shebang - run: dotnet fsi scripts/shebangConvention.fsx - - name: Check there are no mixed line-endings in any files - run: dotnet fsi scripts/mixedLineEndings.fsx - - name: Check there are no unpinned GitHubActions image versions - run: dotnet fsi scripts/unpinnedGitHubActionsImageVersions.fsx - - name: Check there are no unpinned dotnet package versions - run: dotnet fsi scripts/unpinnedDotnetPackageVersions.fsx - - name: Check there are no unpinned nuget package reference versions in F# scripts - run: dotnet fsi scripts/unpinnedNugetPackageReferenceVersions.fsx - name: Check if gitPush1by1 was used if: github.event_name == 'pull_request' run: dotnet fsi scripts/detectNotUsingGitPush1by1.fsx - - name: Install prettier - run: npm install prettier@2.8.3 - - name: Change file permissions - # We need this step so we can change the files using `npx prettier --write` in the next step. - # Otherwise we get permission denied error in the CI. - run: sudo chmod 777 -R . - - name: Run "prettier" to check the style of our TypeScript code - run: | - sudo npx prettier --quote-props=consistent --write './**/*.ts' - # Since we changed file modes in the previous step we need the following command to - # make git ignore mode changes in files and doesn't include them in the git diff command. - git config core.fileMode false - # Since after installing commitlint dependencies package.json file changes, we need to - # run the following command to ignore package.json file - git restore package.json - git diff --exit-code - name: fantomless run: | dotnet new tool-manifest diff --git a/WorkflowGuidelines.md b/WorkflowGuidelines.md index 379e5be7f..a68b14c3b 100644 --- a/WorkflowGuidelines.md +++ b/WorkflowGuidelines.md @@ -1,5 +1,84 @@ # Workflow guidelines +* Avoid typical bad practices like: + + * Magic numbers: + + Avoid using unnamed numerical constants in software code, this practice makes code hard to understand and maintain. + + Example: + ``` + var distance = GpsUtil.GetDistance() + if (distance < 100) + throw new NotImplementedException(); + ``` + ``` + private const int MinimumSupportedDistanceToNotifyKillerDrones = 100; + + ... + + var distance = GpsUtil.GetDistance() + if (distance < MinimumSupportedDistanceToNotifyKillerDrones) + throw new NotImplementedException(); + ``` + + * DRY (Don't Repeat Yourself): + + The DRY principle suggests that a piece of information should only be stored once in a project and should be referenced as needed, rather than being copied and pasted multiple times throughout the codebase. + + It has several benefits, including reducing the amount of code that needs to be written and maintained, improving the consistency and quality of the code, and reducing the risk of introducing errors and bugs when the information changes. + + Example: + ``` + let preAuthInputMac = + CalculateMacWithSHA3256 + preAuthInput + ":hs_mac" + + ... + + let authInputMac = + CalculateMacWithSHA3256 + authInput + ":hs_mac" + ``` + ``` + let AuthenticationDigestCalculationKey = ":hs_mac" + + ... + + let preAuthInputMac = + CalculateMacWithSHA3256 + preAuthInput + AuthenticationDigestCalculationKey + + ... + + let authInputMac = + CalculateMacWithSHA3256 + authInput + AuthenticationDigestCalculationKey + ``` + + * Primitive Obsession: + + Primitive Obsession is a situation where simple data types such as strings, integers, or arrays are overused in place of more appropriate objects. + + Example: + ``` + let saveFilePath = System.Console.ReadLine() + + let savedData = System.IO.File.ReadAllText saveFilePath + ``` + ``` + let saveFilePath = + let saveFilePathInString = + System.Console.ReadLine() + System.IO.FileInfo saveFilePathInString + + let savedData = System.IO.File.ReadAllText saveFilePath.FullName + ``` + * When contributing a PullRequest, separate your commits in units of work (don't mix changes that have different concerns in the same commit). Don't forget to include all explanations and reasonings in the commit messages, @@ -75,3 +154,4 @@ closed after the commit lands, then you would use the word `Closes` instead of Do not use long lines (manually crop them with EOLs because git doesn't do this automatically). + diff --git a/scripts/detectNotUsingGitPush1by1.fsx b/scripts/detectNotUsingGitPush1by1.fsx index 02196d9fd..cf6109a99 100644 --- a/scripts/detectNotUsingGitPush1by1.fsx +++ b/scripts/detectNotUsingGitPush1by1.fsx @@ -1,21 +1,541 @@ #!/usr/bin/env -S dotnet fsi open System +open System.IO open System.Net.Http open System.Net.Http.Headers +#r "nuget: FSharp.Data, Version=5.0.2" +open FSharp.Data + #r "nuget: Fsdk, Version=0.6.0--date20230214-0422.git-1ea6f62" open Fsdk - -let gitRepo = Environment.GetEnvironmentVariable "GITHUB_REPOSITORY" - -if String.IsNullOrEmpty gitRepo then +let githubEventPath = Environment.GetEnvironmentVariable "GITHUB_EVENT_PATH" +printfn "%A" (Environment.GetEnvironmentVariable "GITHUB_EVENT") +if String.IsNullOrEmpty githubEventPath then Console.Error.WriteLine "This script is meant to be used only within a GitHubCI pipeline" Environment.Exit 2 +type githubEventType = + JsonProvider<""" +{ + "action": "opened", + "number": 4, + "pull_request": { + "_links": { + "comments": { + "href": "https://api.github.com/repos/realmarv/conventions/issues/4/comments" + }, + "commits": { + "href": "https://api.github.com/repos/realmarv/conventions/pulls/4/commits" + }, + "html": { + "href": "https://github.com/realmarv/conventions/pull/4" + }, + "issue": { + "href": "https://api.github.com/repos/realmarv/conventions/issues/4" + }, + "review_comment": { + "href": "https://api.github.com/repos/realmarv/conventions/pulls/comments{/number}" + }, + "review_comments": { + "href": "https://api.github.com/repos/realmarv/conventions/pulls/4/comments" + }, + "self": { + "href": "https://api.github.com/repos/realmarv/conventions/pulls/4" + }, + "statuses": { + "href": "https://api.github.com/repos/realmarv/conventions/statuses/c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133" + } + }, + "active_lock_reason": null, + "additions": 21, + "assignee": null, + "assignees": [], + "author_association": "OWNER", + "auto_merge": null, + "base": { + "label": "realmarv:master", + "ref": "master", + "repo": { + "allow_auto_merge": false, + "allow_forking": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "allow_update_branch": false, + "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", + "archived": false, + "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", + "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", + "clone_url": "https://github.com/realmarv/conventions.git", + "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", + "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", + "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", + "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", + "created_at": "2022-10-12T08:48:57Z", + "default_branch": "master", + "delete_branch_on_merge": false, + "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", + "description": null, + "disabled": false, + "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", + "events_url": "https://api.github.com/repos/realmarv/conventions/events", + "fork": true, + "forks": 0, + "forks_count": 0, + "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", + "full_name": "realmarv/conventions", + "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", + "git_url": "git://github.com/realmarv/conventions.git", + "has_discussions": false, + "has_downloads": true, + "has_issues": false, + "has_pages": false, + "has_projects": true, + "has_wiki": true, + "homepage": null, + "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", + "html_url": "https://github.com/realmarv/conventions", + "id": 550128772, + "is_template": false, + "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", + "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", + "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", + "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", + "language": "TypeScript", + "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", + "license": { + "key": "mit", + "name": "MIT License", + "node_id": "MDc6TGljZW5zZTEz", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit" + }, + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE", + "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", + "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", + "mirror_url": null, + "name": "conventions", + "node_id": "R_kgDOIMpMhA", + "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", + "open_issues": 4, + "open_issues_count": 4, + "owner": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + }, + "private": false, + "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", + "pushed_at": "2023-03-23T09:00:26Z", + "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", + "size": 2395, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "ssh_url": "git@github.com:realmarv/conventions.git", + "stargazers_count": 0, + "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", + "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", + "svn_url": "https://github.com/realmarv/conventions", + "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", + "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", + "topics": [], + "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", + "updated_at": "2022-10-13T08:53:39Z", + "url": "https://api.github.com/repos/realmarv/conventions", + "use_squash_pr_title_as_default": false, + "visibility": "public", + "watchers": 0, + "watchers_count": 0, + "web_commit_signoff_required": false + }, + "sha": "0be2f2d608cdf893e146db1296dee750a2a54cfc", + "user": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + } + }, + "body": null, + "changed_files": 2, + "closed_at": null, + "comments": 0, + "comments_url": "https://api.github.com/repos/realmarv/conventions/issues/4/comments", + "commits": 2, + "commits_url": "https://api.github.com/repos/realmarv/conventions/pulls/4/commits", + "created_at": "2023-03-23T09:00:26Z", + "deletions": 0, + "diff_url": "https://github.com/realmarv/conventions/pull/4.diff", + "draft": false, + "head": { + "label": "realmarv:fixGitPush1by1Check", + "ref": "fixGitPush1by1Check", + "repo": { + "allow_auto_merge": false, + "allow_forking": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "allow_update_branch": false, + "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", + "archived": false, + "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", + "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", + "clone_url": "https://github.com/realmarv/conventions.git", + "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", + "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", + "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", + "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", + "created_at": "2022-10-12T08:48:57Z", + "default_branch": "master", + "delete_branch_on_merge": false, + "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", + "description": null, + "disabled": false, + "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", + "events_url": "https://api.github.com/repos/realmarv/conventions/events", + "fork": true, + "forks": 0, + "forks_count": 0, + "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", + "full_name": "realmarv/conventions", + "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", + "git_url": "git://github.com/realmarv/conventions.git", + "has_discussions": false, + "has_downloads": true, + "has_issues": false, + "has_pages": false, + "has_projects": true, + "has_wiki": true, + "homepage": null, + "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", + "html_url": "https://github.com/realmarv/conventions", + "id": 550128772, + "is_template": false, + "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", + "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", + "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", + "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", + "language": "TypeScript", + "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", + "license": { + "key": "mit", + "name": "MIT License", + "node_id": "MDc6TGljZW5zZTEz", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit" + }, + "merge_commit_message": "PR_TITLE", + "merge_commit_title": "MERGE_MESSAGE", + "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", + "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", + "mirror_url": null, + "name": "conventions", + "node_id": "R_kgDOIMpMhA", + "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", + "open_issues": 4, + "open_issues_count": 4, + "owner": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + }, + "private": false, + "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", + "pushed_at": "2023-03-23T09:00:26Z", + "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", + "size": 2395, + "squash_merge_commit_message": "COMMIT_MESSAGES", + "squash_merge_commit_title": "COMMIT_OR_PR_TITLE", + "ssh_url": "git@github.com:realmarv/conventions.git", + "stargazers_count": 0, + "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", + "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", + "svn_url": "https://github.com/realmarv/conventions", + "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", + "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", + "topics": [], + "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", + "updated_at": "2022-10-13T08:53:39Z", + "url": "https://api.github.com/repos/realmarv/conventions", + "use_squash_pr_title_as_default": false, + "visibility": "public", + "watchers": 0, + "watchers_count": 0, + "web_commit_signoff_required": false + }, + "sha": "c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133", + "user": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + } + }, + "html_url": "https://github.com/realmarv/conventions/pull/4", + "id": 1287033164, + "issue_url": "https://api.github.com/repos/realmarv/conventions/issues/4", + "labels": [], + "locked": false, + "maintainer_can_modify": false, + "merge_commit_sha": null, + "mergeable": null, + "mergeable_state": "unknown", + "merged": false, + "merged_at": null, + "merged_by": null, + "milestone": null, + "node_id": "PR_kwDOIMpMhM5MtpFM", + "number": 4, + "patch_url": "https://github.com/realmarv/conventions/pull/4.patch", + "rebaseable": null, + "requested_reviewers": [], + "requested_teams": [], + "review_comment_url": "https://api.github.com/repos/realmarv/conventions/pulls/comments{/number}", + "review_comments": 0, + "review_comments_url": "https://api.github.com/repos/realmarv/conventions/pulls/4/comments", + "state": "open", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/c5eb50ea6c5a72d61ab85d96ffc66cc4741d3133", + "title": "Fix git push1by1 check", + "updated_at": "2023-03-23T09:00:26Z", + "url": "https://api.github.com/repos/realmarv/conventions/pulls/4", + "user": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + } + }, + "repository": { + "allow_forking": true, + "archive_url": "https://api.github.com/repos/realmarv/conventions/{archive_format}{/ref}", + "archived": false, + "assignees_url": "https://api.github.com/repos/realmarv/conventions/assignees{/user}", + "blobs_url": "https://api.github.com/repos/realmarv/conventions/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/realmarv/conventions/branches{/branch}", + "clone_url": "https://github.com/realmarv/conventions.git", + "collaborators_url": "https://api.github.com/repos/realmarv/conventions/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/realmarv/conventions/comments{/number}", + "commits_url": "https://api.github.com/repos/realmarv/conventions/commits{/sha}", + "compare_url": "https://api.github.com/repos/realmarv/conventions/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/realmarv/conventions/contents/{+path}", + "contributors_url": "https://api.github.com/repos/realmarv/conventions/contributors", + "created_at": "2022-10-12T08:48:57Z", + "default_branch": "master", + "deployments_url": "https://api.github.com/repos/realmarv/conventions/deployments", + "description": null, + "disabled": false, + "downloads_url": "https://api.github.com/repos/realmarv/conventions/downloads", + "events_url": "https://api.github.com/repos/realmarv/conventions/events", + "fork": true, + "forks": 0, + "forks_count": 0, + "forks_url": "https://api.github.com/repos/realmarv/conventions/forks", + "full_name": "realmarv/conventions", + "git_commits_url": "https://api.github.com/repos/realmarv/conventions/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/realmarv/conventions/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/realmarv/conventions/git/tags{/sha}", + "git_url": "git://github.com/realmarv/conventions.git", + "has_discussions": false, + "has_downloads": true, + "has_issues": false, + "has_pages": false, + "has_projects": true, + "has_wiki": true, + "homepage": null, + "hooks_url": "https://api.github.com/repos/realmarv/conventions/hooks", + "html_url": "https://github.com/realmarv/conventions", + "id": 550128772, + "is_template": false, + "issue_comment_url": "https://api.github.com/repos/realmarv/conventions/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/realmarv/conventions/issues/events{/number}", + "issues_url": "https://api.github.com/repos/realmarv/conventions/issues{/number}", + "keys_url": "https://api.github.com/repos/realmarv/conventions/keys{/key_id}", + "labels_url": "https://api.github.com/repos/realmarv/conventions/labels{/name}", + "language": "TypeScript", + "languages_url": "https://api.github.com/repos/realmarv/conventions/languages", + "license": { + "key": "mit", + "name": "MIT License", + "node_id": "MDc6TGljZW5zZTEz", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit" + }, + "merges_url": "https://api.github.com/repos/realmarv/conventions/merges", + "milestones_url": "https://api.github.com/repos/realmarv/conventions/milestones{/number}", + "mirror_url": null, + "name": "conventions", + "node_id": "R_kgDOIMpMhA", + "notifications_url": "https://api.github.com/repos/realmarv/conventions/notifications{?since,all,participating}", + "open_issues": 4, + "open_issues_count": 4, + "owner": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + }, + "private": false, + "pulls_url": "https://api.github.com/repos/realmarv/conventions/pulls{/number}", + "pushed_at": "2023-03-23T09:00:26Z", + "releases_url": "https://api.github.com/repos/realmarv/conventions/releases{/id}", + "size": 2395, + "ssh_url": "git@github.com:realmarv/conventions.git", + "stargazers_count": 0, + "stargazers_url": "https://api.github.com/repos/realmarv/conventions/stargazers", + "statuses_url": "https://api.github.com/repos/realmarv/conventions/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/realmarv/conventions/subscribers", + "subscription_url": "https://api.github.com/repos/realmarv/conventions/subscription", + "svn_url": "https://github.com/realmarv/conventions", + "tags_url": "https://api.github.com/repos/realmarv/conventions/tags", + "teams_url": "https://api.github.com/repos/realmarv/conventions/teams", + "topics": [], + "trees_url": "https://api.github.com/repos/realmarv/conventions/git/trees{/sha}", + "updated_at": "2022-10-13T08:53:39Z", + "url": "https://api.github.com/repos/realmarv/conventions", + "visibility": "public", + "watchers": 0, + "watchers_count": 0, + "web_commit_signoff_required": false + }, + "sender": { + "avatar_url": "https://avatars.githubusercontent.com/u/50144546?v=4", + "events_url": "https://api.github.com/users/realmarv/events{/privacy}", + "followers_url": "https://api.github.com/users/realmarv/followers", + "following_url": "https://api.github.com/users/realmarv/following{/other_user}", + "gists_url": "https://api.github.com/users/realmarv/gists{/gist_id}", + "gravatar_id": "", + "html_url": "https://github.com/realmarv", + "id": 50144546, + "login": "realmarv", + "node_id": "MDQ6VXNlcjUwMTQ0NTQ2", + "organizations_url": "https://api.github.com/users/realmarv/orgs", + "received_events_url": "https://api.github.com/users/realmarv/received_events", + "repos_url": "https://api.github.com/users/realmarv/repos", + "site_admin": false, + "starred_url": "https://api.github.com/users/realmarv/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/realmarv/subscriptions", + "type": "User", + "url": "https://api.github.com/users/realmarv" + } + } +"""> + +let jsonString = File.ReadAllText githubEventPath +let parsedJsonObj = githubEventType.Parse jsonString + +let gitForkUser = parsedJsonObj.PullRequest.Head.User.Login +let gitForkRepo = parsedJsonObj.PullRequest.Head.Repo.Name +let gitRepo = $"{gitForkUser}/{gitForkRepo}" + let currentBranch = Process .Execute(