@@ -27,6 +27,10 @@ func (k msgServer) CreatePullRequest(goCtx context.Context, msg *types.MsgCreate
2727 }
2828
2929 headRepository , found := k .GetAddressRepository (ctx , headRepoOwnerAddress .Address , msg .HeadRepositoryId .Name )
30+ if headRepository .Archived {
31+ return nil , fmt .Errorf ("don't allow any modifications to repository %s when archived is set to true" , msg .HeadRepositoryId .Name )
32+ }
33+
3034 if ! found {
3135 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("head-repository (%v/%v) doesn't exist" , msg .HeadRepositoryId .Id , msg .HeadRepositoryId .Name ))
3236 }
@@ -41,6 +45,9 @@ func (k msgServer) CreatePullRequest(goCtx context.Context, msg *types.MsgCreate
4145 }
4246
4347 baseRepository , found := k .GetAddressRepository (ctx , baseRepositoryAddress .Address , msg .BaseRepositoryId .Name )
48+ if baseRepository .Archived {
49+ return nil , fmt .Errorf ("don't allow any modifications to repository %s when archived is set to true" , msg .BaseRepositoryId .Name )
50+ }
4451 if ! found {
4552 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("base-repository (%v/%v) doesn't exist" , msg .BaseRepositoryId .Id , msg .BaseRepositoryId .Name ))
4653 }
@@ -327,6 +334,10 @@ func (k msgServer) InvokeMergePullRequest(goCtx context.Context, msg *types.MsgI
327334 }
328335
329336 baseRepository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
337+ if baseRepository .Archived {
338+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , pullRequest .Base .RepositoryId )
339+ }
340+
330341 if ! found {
331342 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
332343 }
@@ -377,6 +388,9 @@ func (k msgServer) SetPullRequestState(goCtx context.Context, msg *types.MsgSetP
377388 blockTime := ctx .BlockTime ().Unix ()
378389
379390 baseRepository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
391+ if baseRepository .Archived {
392+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , pullRequest .Base .RepositoryId )
393+ }
380394 if ! found {
381395 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
382396 }
@@ -633,6 +647,9 @@ func (k msgServer) AddPullRequestReviewers(goCtx context.Context, msg *types.Msg
633647 }
634648
635649 repository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
650+ if repository .Archived {
651+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
652+ }
636653 if ! found {
637654 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
638655 }
@@ -710,6 +727,10 @@ func (k msgServer) RemovePullRequestReviewers(goCtx context.Context, msg *types.
710727 }
711728
712729 repository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
730+ if repository .Archived {
731+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
732+ }
733+
713734 if ! found {
714735 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
715736 }
@@ -784,6 +805,10 @@ func (k msgServer) AddPullRequestAssignees(goCtx context.Context, msg *types.Msg
784805 }
785806
786807 repository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
808+ if repository .Archived {
809+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
810+ }
811+
787812 if ! found {
788813 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
789814 }
@@ -861,6 +886,10 @@ func (k msgServer) RemovePullRequestAssignees(goCtx context.Context, msg *types.
861886 }
862887
863888 repository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
889+ if repository .Archived {
890+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
891+ }
892+
864893 if ! found {
865894 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
866895 }
@@ -935,6 +964,9 @@ func (k msgServer) LinkPullRequestIssueByIid(goCtx context.Context, msg *types.M
935964 }
936965
937966 baseRepository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
967+ if baseRepository .Archived {
968+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
969+ }
938970 if ! found {
939971 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
940972 }
@@ -1047,6 +1079,10 @@ func (k msgServer) UnlinkPullRequestIssueByIid(goCtx context.Context, msg *types
10471079 }
10481080
10491081 baseRepository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
1082+ if baseRepository .Archived {
1083+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
1084+ }
1085+
10501086 if ! found {
10511087 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
10521088 }
@@ -1153,6 +1189,10 @@ func (k msgServer) AddPullRequestLabels(goCtx context.Context, msg *types.MsgAdd
11531189 }
11541190
11551191 repository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
1192+ if repository .Archived {
1193+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
1194+ }
1195+
11561196 if ! found {
11571197 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
11581198 }
@@ -1234,6 +1274,10 @@ func (k msgServer) RemovePullRequestLabels(goCtx context.Context, msg *types.Msg
12341274 }
12351275
12361276 repository , found := k .GetRepositoryById (ctx , pullRequest .Base .RepositoryId )
1277+ if repository .Archived {
1278+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
1279+ }
1280+
12371281 if ! found {
12381282 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , pullRequest .Base .RepositoryId ))
12391283 }
@@ -1315,6 +1359,10 @@ func (k msgServer) DeletePullRequest(goCtx context.Context, msg *types.MsgDelete
13151359 }
13161360
13171361 repository , found := k .GetRepositoryById (ctx , msg .RepositoryId )
1362+ if repository .Archived {
1363+ return nil , fmt .Errorf ("don't allow any modifications to repository %d when archived is set to true" , msg .RepositoryId )
1364+ }
1365+
13181366 if ! found {
13191367 return nil , sdkerrors .Wrap (sdkerrors .ErrKeyNotFound , fmt .Sprintf ("repository id (%d) doesn't exist" , msg .RepositoryId ))
13201368 }
0 commit comments