File tree 5 files changed +47
-8
lines changed
5 files changed +47
-8
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import type { GitArtifactPayloadAction } from "git/store/types";
7
7
import { call , put , select } from "redux-saga/effects" ;
8
8
import { validateResponse } from "sagas/ErrorSagas" ;
9
9
import handleApiErrors from "./helpers/handleApiErrors" ;
10
+ import { selectProtectedMode } from "git/store/selectors/gitArtifactSelectors" ;
10
11
11
12
export default function * fetchStatusSaga (
12
13
action : GitArtifactPayloadAction < FetchStatusInitPayload > ,
@@ -20,6 +21,22 @@ export default function* fetchStatusSaga(
20
21
selectGitApiContractsEnabled ,
21
22
) ;
22
23
24
+ const isCurrentBranchProtected : boolean = yield select (
25
+ selectProtectedMode ,
26
+ artifactDef ,
27
+ ) ;
28
+
29
+ if ( isCurrentBranchProtected ) {
30
+ // Skip status check for protected branches and set empty status
31
+ yield put (
32
+ gitArtifactActions . resetGitStatus ( {
33
+ artifactDef,
34
+ } ) ,
35
+ ) ;
36
+
37
+ return ;
38
+ }
39
+
23
40
response = yield call (
24
41
fetchStatusRequest ,
25
42
artifactDef . artifactType ,
Original file line number Diff line number Diff line change @@ -36,22 +36,24 @@ export default function* initGitForEditorSaga(
36
36
yield put ( gitArtifactActions . fetchMetadataInit ( { artifactDef } ) ) ;
37
37
yield take ( gitArtifactActions . fetchMetadataSuccess . type ) ;
38
38
39
- if ( isAutocommitEnabled ( artifactDef ) ) {
40
- yield put (
41
- gitArtifactActions . triggerAutocommitInit ( { artifactDef, artifactId } ) ,
42
- ) ;
43
- }
44
-
45
39
yield put (
46
40
gitArtifactActions . fetchBranchesInit ( { artifactDef, artifactId } ) ,
47
41
) ;
48
42
43
+ // We skip the auto-commit and status check for protected branches
44
+ // Hence we need to check if the current branch is protected before triggering auto-commit and status check
49
45
if ( isProtectedBranchesEnabled ( artifactDef ) ) {
50
46
yield put (
51
47
gitArtifactActions . fetchProtectedBranchesInit ( { artifactDef } ) ,
52
48
) ;
53
49
}
54
50
51
+ if ( isAutocommitEnabled ( artifactDef ) ) {
52
+ yield put (
53
+ gitArtifactActions . triggerAutocommitInit ( { artifactDef, artifactId } ) ,
54
+ ) ;
55
+ }
56
+
55
57
yield put (
56
58
gitArtifactActions . fetchStatusInit ( { artifactDef, artifactId } ) ,
57
59
) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ import type {
11
11
} from "git/requests/triggerAutocommitRequest.types" ;
12
12
import type { TriggerAutocommitInitPayload } from "git/store/actions/triggerAutocommitActions" ;
13
13
import { gitArtifactActions } from "git/store/gitArtifactSlice" ;
14
- import { selectAutocommitEnabled } from "git/store/selectors/gitArtifactSelectors" ;
14
+ import {
15
+ selectAutocommitEnabled ,
16
+ selectProtectedMode ,
17
+ } from "git/store/selectors/gitArtifactSelectors" ;
15
18
import type { GitArtifactPayloadAction } from "git/store/types" ;
16
19
import {
17
20
call ,
@@ -142,8 +145,13 @@ export default function* triggerAutocommitSaga(
142
145
selectAutocommitEnabled ,
143
146
artifactDef ,
144
147
) ;
148
+ const isCurrentBranchProtected : boolean = yield select (
149
+ selectProtectedMode ,
150
+ artifactDef ,
151
+ ) ;
152
+ const shouldAutocommit = isAutocommitEnabled && ! isCurrentBranchProtected ;
145
153
146
- if ( isAutocommitEnabled ) {
154
+ if ( shouldAutocommit ) {
147
155
const params = { artifactDef, artifactId } ;
148
156
const pollTask : Task = yield fork ( pollAutocommitProgressSaga , params ) ;
149
157
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export const fetchStatusInitAction =
13
13
createArtifactAction < FetchStatusInitPayload > ( ( state ) => {
14
14
state . apiResponses . status . loading = true ;
15
15
state . apiResponses . status . error = null ;
16
+ state . apiResponses . status . value = null ;
16
17
17
18
return state ;
18
19
} ) ;
@@ -26,6 +27,15 @@ export const fetchStatusSuccessAction = createArtifactAction<
26
27
return state ;
27
28
} ) ;
28
29
30
+ export const resetGitStatusAction =
31
+ createArtifactAction < FetchStatusRequestParams > ( ( state ) => {
32
+ state . apiResponses . status . loading = false ;
33
+ state . apiResponses . status . error = null ;
34
+ state . apiResponses . status . value = null ;
35
+
36
+ return state ;
37
+ } ) ;
38
+
29
39
export const fetchStatusErrorAction =
30
40
createArtifactAction < GitAsyncErrorPayload > ( ( state , action ) => {
31
41
const { error } = action . payload ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
21
21
fetchStatusErrorAction ,
22
22
fetchStatusInitAction ,
23
23
fetchStatusSuccessAction ,
24
+ resetGitStatusAction ,
24
25
} from "./actions/fetchStatusActions" ;
25
26
import {
26
27
clearCommitErrorAction ,
@@ -200,6 +201,7 @@ export const gitArtifactSlice = createSlice({
200
201
clearDiscardError : clearDiscardErrorAction ,
201
202
fetchStatusInit : fetchStatusInitAction ,
202
203
fetchStatusSuccess : fetchStatusSuccessAction ,
204
+ resetGitStatus : resetGitStatusAction ,
203
205
fetchStatusError : fetchStatusErrorAction ,
204
206
fetchMergeStatusInit : fetchMergeStatusInitAction ,
205
207
fetchMergeStatusSuccess : fetchMergeStatusSuccessAction ,
You can’t perform that action at this time.
0 commit comments