Skip to content

Commit

Permalink
Updates provider library and adds mergeable state values/permissions fix
Browse files Browse the repository at this point in the history
  • Loading branch information
axosoft-ramint committed Feb 3, 2025
1 parent ed3de96 commit f4f267a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20117,7 +20117,7 @@
},
"dependencies": {
"@gitkraken/gitkraken-components": "10.7.0",
"@gitkraken/provider-apis": "0.26.1",
"@gitkraken/provider-apis": "0.26.2",
"@gitkraken/shared-web-components": "0.1.1-rc.15",
"@gk-nzaytsev/fast-string-truncated-width": "1.1.0",
"@lit-labs/signals": "0.1.1",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/git/models/pullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ export const enum PullRequestMergeableState {
Unknown = 'Unknown',
Mergeable = 'Mergeable',
Conflicting = 'Conflicting',
FailingChecks = 'FailingChecks',
BlockedByPolicy = 'BlockedByPolicy',
}

export const enum PullRequestStatusCheckRollupState {
Expand Down
4 changes: 4 additions & 0 deletions src/plus/integrations/providers/github/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ export function toGitHubPullRequestMergeableState(
return 'MERGEABLE';
case PullRequestMergeableState.Conflicting:
return 'CONFLICTING';
case PullRequestMergeableState.FailingChecks:
return 'UNKNOWN';
case PullRequestMergeableState.BlockedByPolicy:
return 'UNKNOWN';
case PullRequestMergeableState.Unknown:
return 'UNKNOWN';
}
Expand Down
28 changes: 17 additions & 11 deletions src/plus/integrations/providers/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,14 +701,17 @@ export const toProviderPullRequestMergeableState = {
[PullRequestMergeableState.Mergeable]: GitPullRequestMergeableState.Mergeable,
[PullRequestMergeableState.Conflicting]: GitPullRequestMergeableState.Conflicts,
[PullRequestMergeableState.Unknown]: GitPullRequestMergeableState.Unknown,
[PullRequestMergeableState.FailingChecks]: GitPullRequestMergeableState.FailingChecks,
[PullRequestMergeableState.BlockedByPolicy]: GitPullRequestMergeableState.Blocked,
};

export const fromProviderPullRequestMergeableState = {
[GitPullRequestMergeableState.Mergeable]: PullRequestMergeableState.Mergeable,
[GitPullRequestMergeableState.Conflicts]: PullRequestMergeableState.Conflicting,
[GitPullRequestMergeableState.Blocked]: PullRequestMergeableState.BlockedByPolicy,
[GitPullRequestMergeableState.FailingChecks]: PullRequestMergeableState.FailingChecks,
[GitPullRequestMergeableState.Unknown]: PullRequestMergeableState.Unknown,
[GitPullRequestMergeableState.Behind]: PullRequestMergeableState.Unknown,
[GitPullRequestMergeableState.Blocked]: PullRequestMergeableState.Unknown,
[GitPullRequestMergeableState.UnknownAndBlocked]: PullRequestMergeableState.Unknown,
[GitPullRequestMergeableState.Unstable]: PullRequestMergeableState.Unknown,
};
Expand Down Expand Up @@ -870,16 +873,19 @@ export function toProviderPullRequest(pr: PullRequest): ProviderPullRequest {
],
}
: null,
permissions: {
canMerge:
pr.viewerCanUpdate === true &&
pr.repository.accessLevel != null &&
pr.repository.accessLevel >= RepositoryAccessLevel.Write,
canMergeAndBypassProtections:
pr.viewerCanUpdate === true &&
pr.repository.accessLevel != null &&
pr.repository.accessLevel >= RepositoryAccessLevel.Admin,
},
permissions:
pr.viewerCanUpdate == null
? null
: {
canMerge:
pr.viewerCanUpdate === true &&
pr.repository.accessLevel != null &&
pr.repository.accessLevel >= RepositoryAccessLevel.Write,
canMergeAndBypassProtections:
pr.viewerCanUpdate === true &&
pr.repository.accessLevel != null &&
pr.repository.accessLevel >= RepositoryAccessLevel.Admin,
},
mergeableState: pr.mergeableState
? toProviderPullRequestMergeableState[pr.mergeableState]
: GitPullRequestMergeableState.Unknown,
Expand Down

0 comments on commit f4f267a

Please sign in to comment.