Commit 586dd4d
authored
🚀 [Breaking pre-release]: Refactor GitHubPermission and improve initialization and comparison logic (#524)
## Description
This pull request refactors how GitHub permissions are represented and
handled throughout the codebase, consolidating the
`GitHubPermissionDefinition` and `GitHubPermission` classes and updating
related logic for consistency and correctness. The changes also improve
the handling of permissions and events in context and installation
classes, as well as streamline status calculation for installations.
### Refactoring and Consolidation of Permissions
* Merged `GitHubPermissionDefinition` into a single `GitHubPermission`
class, adding constructors and properties to better represent both
definitions and assigned values. All static permission lists and related
logic now use `GitHubPermission` instead of the previous definition
class.
* Updated all permission list instantiations to use the new
`GitHubPermission` class, ensuring consistent construction and type
usage.
### Improvements to Installation and Context Classes
* Updated constructors in `GitHubAppInstallation.ps1` to use a simpler
parameter set, replaced `$Context.HostName` with direct `$HostName`
usage, and removed a redundant constructor. Also changed the status
update method name from `UpdateStatus` to `SetStatus` and adjusted its
usage.
* Improved event and permission handling in `GitHubAppContext.ps1` and
`GitHubAppInstallationContext.ps1` by ensuring events are always stored
as arrays and permissions are only set when present.
* Ensured `FilePaths` and `Events` properties are always arrays to
prevent type inconsistencies.
### Streamlining Installation Status Calculation
* Refactored the logic for comparing permissions in `SetStatus`,
replacing manual dictionary comparison with a simpler `Compare-Object`
approach for determining if permissions match between app and
installation.
* Added a check to ensure that installation permissions exist before
attempting status calculation, improving robustness.
## Type of change
<!-- Use the check-boxes [x] on the options that are relevant. -->
- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [ ] 🩹 [Patch]
- [ ] 1 parent 5bde93c commit 586dd4d
File tree
21 files changed
+1411
-1603
lines changed- src
- classes/public
- App
- Context/GitHubContext
- functions
- private
- Apps/GitHub Apps
- Auth/Context
- public
- Apps
- GitHub App Installations
- GitHub App
- Auth
- Permission
- tests
- tools/utilities
21 files changed
+1411
-1603
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | 114 | | |
136 | 115 | | |
137 | | - | |
| 116 | + | |
138 | 117 | | |
139 | 118 | | |
140 | 119 | | |
141 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
142 | 125 | | |
143 | 126 | | |
144 | 127 | | |
| |||
156 | 139 | | |
157 | 140 | | |
158 | 141 | | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 142 | + | |
191 | 143 | | |
192 | 144 | | |
193 | 145 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
0 commit comments