From 8616a5add684d9330732a8eb399de25f5b6f77ea Mon Sep 17 00:00:00 2001 From: k-mouline Date: Fri, 25 Oct 2024 12:52:06 -0400 Subject: [PATCH] Refactored error message slightly and fixed regex --- forge/send-to-kodkod.rkt | 23 ++++++++++++++--------- forge/shared.rkt | 4 ++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/forge/send-to-kodkod.rkt b/forge/send-to-kodkod.rkt index 85a0a929..dec77475 100644 --- a/forge/send-to-kodkod.rkt +++ b/forge/send-to-kodkod.rkt @@ -60,15 +60,20 @@ (when (and no-version-printed-yet (@>= (get-verbosity) VERBOSITY_LOW)) (set! no-version-printed-yet #f) (printf "Forge version: ~a~n" forge-version) - (let ([curr-forge-version (curr-forge-version)]) - (cond [(not (void? curr-forge-version)) - (if (equal? forge-version curr-forge-version) - (printf "Forge is up-to-date.~n") - (printf "Forge is out-of-date. You are on version ~a, but the latest version is ~a.~n" - forge-version curr-forge-version))])) - (let ([git-info (forge-git-info)]) - (when (pair? git-info) - (apply printf " branch: ~a~n commit: ~a~n timestamp: ~a~n" git-info))) + (let* ([git-info (forge-git-info)] + [git-valid (pair? git-info)]) + (when git-valid + (apply printf " branch: ~a~n commit: ~a~n timestamp: ~a~n" git-info) + ; Check local forge version vs. latest version on main branch + (let ([curr-forge-version (curr-forge-version)]) + (cond [(and (not (void? curr-forge-version)) (and git-valid (equal? (car git-info) "main"))) + (if (equal? forge-version curr-forge-version) + (printf "Forge is up-to-date.~n") + (printf "Forge is out-of-date. You are on version ~a, but main is on version ~a.~n" + forge-version curr-forge-version))] + [(or (not git-valid) (not (equal? (car git-info) "main"))) + (printf "Skipping version check vs. main branch.~n")])))) + (printf "To report issues with Forge, please visit ~a~n" "https://report.forge-fm.org")) diff --git a/forge/shared.rkt b/forge/shared.rkt index 41a4e00e..d4f2f512 100644 --- a/forge/shared.rkt +++ b/forge/shared.rkt @@ -2,7 +2,7 @@ (require racket/runtime-path racket/file) (require (only-in racket/draw color%) - (only-in racket make-object match) + (only-in racket make-object) (only-in racket/system system*) (only-in racket/string string-trim) (only-in racket/port call-with-output-string) @@ -70,7 +70,7 @@ [json-data (string->jsexpr (bytes->string/utf-8 body))] [content (hash-ref json-data 'content)] [decoded-content (bytes->string/utf-8 (base64-decode (string->bytes/utf-8 content)))] - [version (regexp-match #px"\\(define version \"([0-9]+\\.[0-9]+)\"\\)" decoded-content)]) + [version (regexp-match #px"\\(define version \"([0-9]+[.0-9]+)\"\\)" decoded-content)]) (car (cdr version))) void)))