-
Notifications
You must be signed in to change notification settings - Fork 4.5k
chore: Added git resource map types #37746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.appsmith.external.git.models; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.NonNull; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Data | ||
| @RequiredArgsConstructor | ||
| public class GitResourceIdentity { | ||
| // TODO @Nidhi should we persist the info from parsing this filePath ? | ||
| String filePath; | ||
|
|
||
| // TODO @Nidhi should we persist this sha against the Appsmith domain to integrate with the isModified logic? | ||
| String sha; | ||
|
Comment on lines
+14
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider SHA validation and resolve TODO comment The SHA field might benefit from:
- String sha;
+ @Pattern(regexp = "[0-9a-f]{40}", message = "Must be a valid SHA-1 hash")
+ String sha;
|
||
|
|
||
| @NonNull @EqualsAndHashCode.Include | ||
| GitResourceType resourceType; | ||
|
|
||
| // This is gitSyncId for most resources, where available | ||
| // It could otherwise point to whatever defines uniqueness for that resource | ||
| // Exceptions: widgets, jsLibs, json files in root dir | ||
| // widgets -> pageGitSyncId-widgetId | ||
| // jsLibs -> jsLibFileName | ||
| // root dir files -> fileName | ||
| @NonNull @EqualsAndHashCode.Include | ||
| String resourceIdentifier; | ||
|
Comment on lines
+20
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add validation for resourceIdentifier formats The documentation indicates different formats for widgets, jsLibs, and root dir files. Consider adding validation to ensure the format matches the resourceType. @AssertTrue(message = "Invalid resource identifier format")
private boolean isResourceIdentifierValid() {
if (resourceType == null || resourceIdentifier == null) {
return false;
}
switch (resourceType) {
case WIDGET:
return resourceIdentifier.matches(".*-.*"); // pageGitSyncId-widgetId
case JS_LIB:
return resourceIdentifier.matches(".*\\.js$"); // jsLibFileName
// Add other cases
default:
return true;
}
} |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.appsmith.external.git.models; | ||
|
|
||
| import com.appsmith.external.dtos.ModifiedResources; | ||
| import lombok.Data; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
|
|
||
| @Data | ||
| public class GitResourceMap { | ||
|
|
||
| private Map<GitResourceIdentity, Object> gitResourceMap = new ConcurrentHashMap<>(); | ||
|
|
||
| private ModifiedResources modifiedResources; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.appsmith.external.git.models; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| public enum GitResourceType { | ||
| ROOT_CONFIG, | ||
| DATASOURCE_CONFIG, | ||
| JSLIB_CONFIG, | ||
| PAGE_CONFIG, | ||
| JSOBJECT_CONFIG, | ||
| JSOBJECT_DATA, | ||
| QUERY_CONFIG, | ||
| QUERY_DATA, | ||
| WIDGET_CONFIG, | ||
| ; | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return this.name().toLowerCase(Locale.ROOT); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Based on the analysis of the codebase, I can generate the final response:
Add @nonnull annotation and remove TODO comment
The filePath field is a critical part of GitResourceIdentity and is used extensively throughout the codebase for file operations, particularly in git-related functionality. The field should never be null as evidenced by its usage in FileOperationsCE interface and its implementations.
🔗 Analysis chain
Address TODO comment and consider field constraints
The TODO comment needs resolution before proceeding. Additionally, consider:
Let's analyze the usage patterns of filePath and similar fields to determine if @nonnull is commonly used and how filePath is validated or processed.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 36
Script:
Length of output: 37266