mirror of
				https://code.forgejo.org/actions/cache.git
				synced 2025-11-04 06:19:11 +00:00 
			
		
		
		
	Merge pull request #1013 from jongwooo/refactor/use-early-return-pattern-to-avoid-nested-conditions
refactor: Use early return pattern to avoid nested conditions
This commit is contained in:
		
						commit
						a2f324eeb7
					
				
					 3 changed files with 26 additions and 27 deletions
				
			
		
							
								
								
									
										11
									
								
								dist/restore/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								dist/restore/index.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -38489,17 +38489,16 @@ function getInputAsInt(name, options) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.getInputAsInt = getInputAsInt;
 | 
					exports.getInputAsInt = getInputAsInt;
 | 
				
			||||||
function isCacheFeatureAvailable() {
 | 
					function isCacheFeatureAvailable() {
 | 
				
			||||||
    if (!cache.isFeatureAvailable()) {
 | 
					    if (cache.isFeatureAvailable()) {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (isGhes()) {
 | 
					    if (isGhes()) {
 | 
				
			||||||
        logWarning(`Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
 | 
					        logWarning(`Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
 | 
				
			||||||
Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`);
 | 
					Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`);
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            logWarning("An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return true;
 | 
					    logWarning("An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.");
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
 | 
					exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										11
									
								
								dist/save/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								dist/save/index.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -38489,17 +38489,16 @@ function getInputAsInt(name, options) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.getInputAsInt = getInputAsInt;
 | 
					exports.getInputAsInt = getInputAsInt;
 | 
				
			||||||
function isCacheFeatureAvailable() {
 | 
					function isCacheFeatureAvailable() {
 | 
				
			||||||
    if (!cache.isFeatureAvailable()) {
 | 
					    if (cache.isFeatureAvailable()) {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (isGhes()) {
 | 
					    if (isGhes()) {
 | 
				
			||||||
        logWarning(`Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
 | 
					        logWarning(`Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
 | 
				
			||||||
Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`);
 | 
					Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`);
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            logWarning("An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return true;
 | 
					    logWarning("An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions.");
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
 | 
					exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,19 +77,20 @@ export function getInputAsInt(
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function isCacheFeatureAvailable(): boolean {
 | 
					export function isCacheFeatureAvailable(): boolean {
 | 
				
			||||||
    if (!cache.isFeatureAvailable()) {
 | 
					    if (cache.isFeatureAvailable()) {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (isGhes()) {
 | 
					    if (isGhes()) {
 | 
				
			||||||
        logWarning(
 | 
					        logWarning(
 | 
				
			||||||
            `Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
 | 
					            `Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.
 | 
				
			||||||
Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`
 | 
					Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            logWarning(
 | 
					 | 
				
			||||||
                "An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."
 | 
					 | 
				
			||||||
            );
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return true;
 | 
					    logWarning(
 | 
				
			||||||
 | 
					        "An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue