Update ringpm/commands/update.ring - Better Code
*/
func UpdatePackage cPackageName
- # Get Package File (Local & Remote) ---> Compare
+ # Get Branch Name
cLocalPackageFile = GetLocalPackageFile(cPackageName)
if cLocalPackageFile = NULL return ok
eval(cLocalPackageFile)
+ cBranchName = aPackageInfo[:branch]
+ # Check if no updates (---> Return)
+ if CheckPackageUpdate(cPackageName) = False
+ ? C_ERROR_NOUPDATES
+ ? "Package Name : " + cPackageName
+ return
+ ok
+ # Install Update
+ Style("Updating ",:YellowBlack) ? cPackageName
+ GetPackage(cPackageName,cBranchName,True) # True = Update Operation (Not Install)
+
+func CheckPackageUpdate cPackageName
+ # Get Package File (Local & Remote) ---> Compare
+ cLocalPackageFile = GetLocalPackageFile(cPackageName)
+ if cLocalPackageFile = NULL return False ok
+ eval(cLocalPackageFile)
cLocalVersion = aPackageInfo[:version]
cBranchName = aPackageInfo[:branch]
# Remove branch name from package name
- if cBranchName != NULL and cBranchName != "master"
- if len(cPackageName) > len(cBranchName)
- cPackageName = left(cPackageName,len(cPackageName)- len(cBranchName))
- ok
- ok
+ cPackageName = RemoveBranchNameFromPackageName(cPackageName,cBranchName)
cRemotePackageFile = GetPackageFile(cPackageName,aPackageInfo[:branch])
- if cRemotePackageFile = "" return ok
+ if cRemotePackageFile = "" return False ok
eval(cRemotePackageFile)
cRemoteVersion = aPackageInfo[:version]
# Check if no updates (---> Return)
if cLocalVersion = cRemoteVersion
- ? C_ERROR_NOUPDATES
- ? "Package Name : " + cPackageName
- return
+ return False
ok
- # Install Update
- Style("Update ",:YellowBlack) ? cPackageName
- GetPackage(cPackageName,cBranchName,True) # True = Update Operation (Not Install)
+ return True
+
+func RemoveBranchNameFromPackageName cPackageName,cBranchName
+ if cBranchName != NULL and cBranchName != "master"
+ if len(cPackageName) > len(cBranchName)
+ cPackageName = left(cPackageName,len(cPackageName)- len(cBranchName))
+ ok
+ ok
+ return cPackageName
