54
pio-scripts/set_repo.py
Normal file
54
pio-scripts/set_repo.py
Normal file
@@ -0,0 +1,54 @@
|
||||
Import('env')
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
def get_github_repo():
|
||||
"""Extract GitHub repository name from git remote URL.
|
||||
|
||||
Returns:
|
||||
str: Repository name in 'owner/repo' format for GitHub repos,
|
||||
'unknown' for non-GitHub repos, missing git CLI, or any errors.
|
||||
"""
|
||||
try:
|
||||
# Get the remote URL for origin
|
||||
result = subprocess.run(['git', 'remote', 'get-url', 'origin'],
|
||||
capture_output=True, text=True, check=True)
|
||||
remote_url = result.stdout.strip()
|
||||
|
||||
# Check if it's a GitHub URL
|
||||
if 'github.com' not in remote_url.lower():
|
||||
return 'unknown'
|
||||
|
||||
# Parse GitHub URL patterns:
|
||||
# https://github.com/owner/repo.git
|
||||
# git@github.com:owner/repo.git
|
||||
# https://github.com/owner/repo
|
||||
|
||||
# Remove .git suffix if present
|
||||
if remote_url.endswith('.git'):
|
||||
remote_url = remote_url[:-4]
|
||||
|
||||
# Handle HTTPS URLs
|
||||
https_match = re.search(r'github\.com/([^/]+/[^/]+)', remote_url, re.IGNORECASE)
|
||||
if https_match:
|
||||
return https_match.group(1)
|
||||
|
||||
# Handle SSH URLs
|
||||
ssh_match = re.search(r'github\.com:([^/]+/[^/]+)', remote_url, re.IGNORECASE)
|
||||
if ssh_match:
|
||||
return ssh_match.group(1)
|
||||
|
||||
return 'unknown'
|
||||
|
||||
except FileNotFoundError:
|
||||
# Git CLI is not installed or not in PATH
|
||||
return 'unknown'
|
||||
except subprocess.CalledProcessError:
|
||||
# Git command failed (e.g., not a git repo, no remote, etc.)
|
||||
return 'unknown'
|
||||
except Exception:
|
||||
# Any other unexpected error
|
||||
return 'unknown'
|
||||
|
||||
repo = get_github_repo()
|
||||
env.Append(BUILD_FLAGS=[f'-DWLED_REPO=\\"{repo}\\"'])
|
||||
@@ -222,6 +222,7 @@ extra_scripts =
|
||||
pre:pio-scripts/set_version.py
|
||||
pre:pio-scripts/build_ui.py
|
||||
pre:pio-scripts/conditional_usb_mode.py
|
||||
pre:pio-scripts/set_repo.py
|
||||
post:pio-scripts/output_bins.py
|
||||
post:pio-scripts/strip-floats.py
|
||||
pre:pio-scripts/user_config_copy.py
|
||||
|
||||
@@ -102,7 +102,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
esp32SemGive(segmentMux);
|
||||
} else {
|
||||
USER_PRINTLN(F("deserializeSegment(): segment not added - failed to acquire segmentMux."));
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,7 +452,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
||||
|
||||
bool stateResponse = root[F("v")] | false;
|
||||
|
||||
//WLEDMM: store netDebug, also if not WLED_DEBUG
|
||||
//WLEDMM: store netDebug, also if not WLED_DEBUG
|
||||
#if defined(WLED_DEBUG_HOST)
|
||||
bool oldValue = netDebugEnabled;
|
||||
netDebugEnabled = root[F("netDebug")] | netDebugEnabled;
|
||||
@@ -566,7 +566,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
||||
realtimeLock(65000);
|
||||
#else
|
||||
// more meaningful timeout : use configurable timeout; *3 for some safety margin without staying "live" forever
|
||||
realtimeLock(realtimeTimeoutMs *3); // Use configurable timeout like other protocols
|
||||
realtimeLock(realtimeTimeoutMs *3); // Use configurable timeout like other protocols
|
||||
#endif
|
||||
} else {
|
||||
exitRealtime();
|
||||
@@ -764,7 +764,7 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
|
||||
}
|
||||
|
||||
if (!forPreset) {
|
||||
//WLEDMM: store netDebug
|
||||
//WLEDMM: store netDebug
|
||||
#if defined(WLED_DEBUG_HOST)
|
||||
root[F("netDebug")] = netDebugEnabled;
|
||||
// USER_PRINTF("serializeState %d\n", netDebugEnabled);
|
||||
@@ -876,7 +876,7 @@ String resetCode2Info(int reason) {
|
||||
// unknown reason code
|
||||
case 0:
|
||||
return F(""); break;
|
||||
default:
|
||||
default:
|
||||
return F("unknown"); break;
|
||||
}
|
||||
}
|
||||
@@ -954,7 +954,7 @@ void serializeInfo(JsonObject root)
|
||||
//root[F("cn")] = F(WLED_CODENAME); //WLEDMM removed
|
||||
root[F("release")] = FPSTR(releaseString);
|
||||
root[F("rel")] = FPSTR(releaseString); //WLEDMM to add bin name
|
||||
//root[F("repo")] = repoString; // WLEDMM not availeable
|
||||
root[F("repo")] = repoString;
|
||||
root[F("deviceId")] = getDeviceId();
|
||||
|
||||
JsonObject leds = root.createNestedObject("leds");
|
||||
@@ -1157,8 +1157,8 @@ void serializeInfo(JsonObject root)
|
||||
// use the full revision if we can
|
||||
esp_chip_info_t chip_info;
|
||||
esp_chip_info(&chip_info);
|
||||
snprintf(msgbuf, sizeof(msgbuf)-1, "%s v%u.%u",
|
||||
ESP.getChipModel(),
|
||||
snprintf(msgbuf, sizeof(msgbuf)-1, "%s v%u.%u",
|
||||
ESP.getChipModel(),
|
||||
unsigned(chip_info.full_revision / 100), // full revision is in (major * 100 + minor) format
|
||||
unsigned(chip_info.full_revision % 100));
|
||||
#else
|
||||
@@ -1406,7 +1406,7 @@ void serializePalettes(JsonObject root, AsyncWebServerRequest* request)
|
||||
// WLEDMM workaround for palettes index overflow at i=74 -> gGradientPalettes index=61 out of bounds.
|
||||
int palIndex = i-13;
|
||||
constexpr int palMax = sizeof(gGradientPalettes)/sizeof(gGradientPalettes[0]) -1;
|
||||
if ((palIndex < 0) || (palIndex > palMax)) {
|
||||
if ((palIndex < 0) || (palIndex > palMax)) {
|
||||
DEBUG_PRINTF("WARNING gGradientPalettes[%d] is out of bounds! max=%d. (json.cpp)\n", palIndex, palMax);
|
||||
palIndex = palMax; // use last valid array item
|
||||
}
|
||||
@@ -1638,7 +1638,7 @@ bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient)
|
||||
}
|
||||
#endif
|
||||
|
||||
DynamicBuffer buffer(9 + (9*MAX_LIVE_LEDS) + 7 + 5 + 6 + 5 + 6 + 5 + 2);
|
||||
DynamicBuffer buffer(9 + (9*MAX_LIVE_LEDS) + 7 + 5 + 6 + 5 + 6 + 5 + 2);
|
||||
char* buf = buffer.data(); // assign buffer for oappnd() functions
|
||||
strncpy_P(buffer.data(), PSTR("{\"leds\":["), buffer.size());
|
||||
buf += 9; // sizeof(PSTR()) from last line
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
||||
#define _MoonModules_WLED_
|
||||
|
||||
//WLEDMM + Moustachauve/Wled-Native
|
||||
//WLEDMM + Moustachauve/Wled-Native
|
||||
// You can define custom product info from build flags.
|
||||
// This is useful to allow API consumer to identify what type of WLED version
|
||||
// they are interacting with. Be aware that changing this might cause some third
|
||||
@@ -50,8 +50,8 @@
|
||||
#ifndef WLED_DISABLE_MQTT
|
||||
#define WLED_ENABLE_MQTT // saves 12kb
|
||||
#endif
|
||||
#ifndef WLED_DISABLE_ADALIGHT // can be used to disable reading commands from serial RX pin (see issue #3128).
|
||||
#define WLED_ENABLE_ADALIGHT // disable saves 5Kb (uses GPIO3 (RX) for serial). Related serial protocols: Adalight/TPM2, Improv, Serial JSON, Continuous Serial Streaming
|
||||
#ifndef WLED_DISABLE_ADALIGHT // can be used to disable reading commands from serial RX pin (see issue #3128).
|
||||
#define WLED_ENABLE_ADALIGHT // disable saves 5Kb (uses GPIO3 (RX) for serial). Related serial protocols: Adalight/TPM2, Improv, Serial JSON, Continuous Serial Streaming
|
||||
#else
|
||||
#undef WLED_ENABLE_ADALIGHT // disable has priority over enable
|
||||
#endif
|
||||
@@ -65,7 +65,7 @@
|
||||
#define WLED_ENABLE_WEBSOCKETS
|
||||
#endif
|
||||
|
||||
//#define WLED_DISABLE_ESPNOW // Removes dependence on esp now
|
||||
//#define WLED_DISABLE_ESPNOW // Removes dependence on esp now
|
||||
|
||||
#define WLED_ENABLE_FS_EDITOR // enable /edit page for editing FS content. Will also be disabled with OTA lock
|
||||
|
||||
@@ -296,10 +296,14 @@ using PSRAMDynamicJsonDocument = BasicJsonDocument<PSRAM_Allocator>;
|
||||
#ifndef WLED_RELEASE_NAME
|
||||
#define WLED_RELEASE_NAME mdev_release
|
||||
#endif
|
||||
#ifndef WLED_REPO
|
||||
#define WLED_REPO "unknown"
|
||||
#endif
|
||||
|
||||
// Global Variable definitions
|
||||
WLED_GLOBAL char versionString[] _INIT(TOSTRING(WLED_VERSION));
|
||||
WLED_GLOBAL char releaseString[] _INIT_PROGMEM(TOSTRING(WLED_RELEASE_NAME)); //WLEDMM: to show on update page // somehow this will not work if using "const char releaseString[]
|
||||
WLED_GLOBAL char repoString[] _INIT(WLED_REPO);
|
||||
#define WLED_CODENAME "Hoshi"
|
||||
|
||||
// AP and OTA default passwords (for maximum security change them!)
|
||||
|
||||
Reference in New Issue
Block a user