fix: do not create files for empty body of queries in the git repo (#21774)

We're currently creating an empty txt file even when there is no body
for an API call. For eg, in GET API calls. We should check whether there
is content in a file before creating the file.

Fixes #21683
This commit is contained in:
Anagh Hegde 2023-03-30 15:53:10 +05:30 committed by GitHub
parent f1e6ad6849
commit bfeab838f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -414,7 +414,7 @@ public class FileUtilsImpl implements FileInterface {
Files.createDirectories(path);
// Write the user written query to .txt file to make conflict handling easier
// Body will be null if the action is of type JS
if (body != null) {
if (StringUtils.hasLength(body)) {
Path bodyPath = path.resolve(resourceName + CommonConstants.TEXT_FILE_EXTENSION);
writeStringToFile(body, bodyPath);
}

View File

@ -494,8 +494,9 @@ public class GitExecutorImpl implements GitExecutor {
for (String x : modifiedAssets) {
if (x.contains(CommonConstants.CANVAS)) {
modifiedPages++;
} else if (x.contains(GitDirectories.ACTION_DIRECTORY + "/") && !x.endsWith(".json")) {
String queryName = x.substring(x.lastIndexOf("/") + 1);
} else if (x.contains(GitDirectories.ACTION_DIRECTORY + "/")) {
String queryName = x.split(GitDirectories.ACTION_DIRECTORY + "/")[1];
queryName = queryName.substring(0, queryName.indexOf("/"));
String pageName = x.split("/")[1];
if (!queriesModified.contains(pageName + queryName)) {
queriesModified.add(pageName + queryName);