Signature contains git branch (#4950)
* back to full signature * Put the branch name in the signature file * I guess branch should go first * parse branch in java code that touches it * I can't count * don't warn if we intentionally skipped this spark * Revert "don't warn if we intentionally skipped this spark" This reverts commit d89b7eb619dcdd9748beea3869ca10cb29664e0e. * other tests * happy test
This commit is contained in:
parent
37e0c27c98
commit
a11ac3a207
|
@ -14,6 +14,10 @@ echo "! Generated by gen_signature.sh" > ${SIGNATURE_FILE_NAME}
|
|||
|
||||
echo "! SIGNATURE_HASH is a built-in variable generated by ConfigDefinition.jar" >> ${SIGNATURE_FILE_NAME}
|
||||
|
||||
echo "#define TS_SIGNATURE \"rusEFI $date.${SHORT_BOARDNAME}.@@SIGNATURE_HASH@@\"" >> ${SIGNATURE_FILE_NAME}
|
||||
# read the current git branch name
|
||||
branchname=`git branch --show-current`
|
||||
echo "! Current branch is: $branchname" >> ${SIGNATURE_FILE_NAME}
|
||||
|
||||
echo "#define TS_SIGNATURE \"rusEFI $branchname.$date.${SHORT_BOARDNAME}.@@SIGNATURE_HASH@@\"" >> ${SIGNATURE_FILE_NAME}
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -28,22 +28,24 @@ echo "[upload_ini] Looking for signature in [$fileName]..."
|
|||
sig=$(grep "^\s*signature\s*=" $fileName | cut -f2 -d "=")
|
||||
if [ ! -z "$sig" -a "$sig" != " " ]; then
|
||||
echo "* found signature: $sig"
|
||||
if [[ "$sig" =~ rusEFI.*([0-9]{4})\.([0-9]{2})\.([0-9]{2})\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+) ]]; then
|
||||
year=${BASH_REMATCH[1]}
|
||||
month=${BASH_REMATCH[2]}
|
||||
day=${BASH_REMATCH[3]}
|
||||
board=${BASH_REMATCH[4]}
|
||||
hash=${BASH_REMATCH[5]}
|
||||
path="$year/$month/$day/$board/$hash.ini"
|
||||
if [[ "$sig" =~ rusEFI\ ([a-zA-Z0-9_-]+)\.([0-9]{4})\.([0-9]{2})\.([0-9]{2})\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+) ]]; then
|
||||
branch=${BASH_REMATCH[1]}
|
||||
year=${BASH_REMATCH[2]}
|
||||
month=${BASH_REMATCH[3]}
|
||||
day=${BASH_REMATCH[4]}
|
||||
board=${BASH_REMATCH[5]}
|
||||
hash=${BASH_REMATCH[6]}
|
||||
path="$branch/$year/$month/$day/$board/$hash.ini"
|
||||
echo "* found path: $path"
|
||||
# we do not have ssh for this user
|
||||
# sftp does not support -p flag on mkdir :(
|
||||
sshpass -p $3 sftp -o StrictHostKeyChecking=no $2@$4 <<SSHCMD
|
||||
cd rusefi
|
||||
mkdir $year
|
||||
mkdir $year/$month
|
||||
mkdir $year/$month/$day
|
||||
mkdir $year/$month/$day/$board
|
||||
mkdir $branch
|
||||
mkdir $branch/$year
|
||||
mkdir $branch/$year/$month
|
||||
mkdir $branch/$year/$month/$day
|
||||
mkdir $branch/$year/$month/$day/$board
|
||||
put $fileName $path
|
||||
SSHCMD
|
||||
retVal=$?
|
||||
|
|
|
@ -9,8 +9,9 @@ import static org.junit.Assert.assertEquals;
|
|||
public class SignatureHelperTest {
|
||||
@Test
|
||||
public void parseSignature() {
|
||||
RusEfiSignature s = SignatureHelper.parse("rusEFI 2021.09.22.all.3378169541");
|
||||
RusEfiSignature s = SignatureHelper.parse("rusEFI master.2021.09.22.all.3378169541");
|
||||
|
||||
assertEquals("master", s.getBranch());
|
||||
assertEquals("all", s.getBundle());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ import static org.junit.Assert.assertTrue;
|
|||
|
||||
public class TestHelper extends MockitoTestHelper {
|
||||
private static final Logging log = getLogging(TestHelper.class);
|
||||
public static final String TEST_SIGNATURE_1 = "rusEFI 2020.07.06.frankenso_na6.2468827536";
|
||||
public static final String TEST_SIGNATURE_2 = "rusEFI 2020.07.11.proteus_f4.1986715563";
|
||||
public static final String TEST_SIGNATURE_1 = "rusEFI master.2020.07.06.frankenso_na6.2468827536";
|
||||
public static final String TEST_SIGNATURE_2 = "rusEFI master.2020.07.11.proteus_f4.1986715563";
|
||||
public static final ControllerInfo CONTROLLER_INFO = new ControllerInfo("name", "make", "code", Fields.TS_SIGNATURE);
|
||||
public static final String TEST_TOKEN_1 = "00000000-1234-1234-1234-123456789012";
|
||||
public static final String TEST_TOKEN_3 = "33333333-3333-1234-1234-123456789012";
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package com.rusefi.core;
|
||||
|
||||
public class RusEfiSignature {
|
||||
private final String branch;
|
||||
private final String year;
|
||||
private final String month;
|
||||
private final String day;
|
||||
private final String bundle;
|
||||
private final String hash;
|
||||
|
||||
public RusEfiSignature(String year, String month, String day, String bundle, String hash) {
|
||||
|
||||
public RusEfiSignature(String branch, String year, String month, String day, String bundle, String hash) {
|
||||
this.branch = branch;
|
||||
this.year = year;
|
||||
this.month = month;
|
||||
this.day = day;
|
||||
|
@ -16,6 +17,10 @@ public class RusEfiSignature {
|
|||
this.hash = hash;
|
||||
}
|
||||
|
||||
public String getBranch() {
|
||||
return branch;
|
||||
}
|
||||
|
||||
public String getYear() {
|
||||
return year;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class SignatureHelper {
|
|||
return null;
|
||||
|
||||
String fileName = s.getHash() + ".ini";
|
||||
return new Pair("https://rusefi.com/online/ini/rusefi/" + s.getYear() + SLASH +
|
||||
return new Pair("https://rusefi.com/online/ini/rusefi/" + s.getBranch() + SLASH + s.getYear() + SLASH +
|
||||
s.getMonth() + SLASH +
|
||||
s.getDay() + SLASH +
|
||||
s.getBundle() + SLASH +
|
||||
|
@ -55,15 +55,16 @@ public class SignatureHelper {
|
|||
return null;
|
||||
signature = signature.substring(PREFIX.length()).trim();
|
||||
String[] elements = signature.split("\\.");
|
||||
if (elements.length != 5)
|
||||
if (elements.length != 6)
|
||||
return null;
|
||||
|
||||
String year = elements[0];
|
||||
String month = elements[1];
|
||||
String day = elements[2];
|
||||
String bundle = elements[3];
|
||||
String hash = elements[4];
|
||||
String branch = elements[0];
|
||||
String year = elements[1];
|
||||
String month = elements[2];
|
||||
String day = elements[3];
|
||||
String bundle = elements[4];
|
||||
String hash = elements[5];
|
||||
|
||||
return new RusEfiSignature(year, month, day, bundle, hash);
|
||||
return new RusEfiSignature(branch, year, month, day, bundle, hash);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -12,6 +12,6 @@ public class FirmwareVersion {
|
|||
|
||||
@NotNull
|
||||
public String encode() {
|
||||
return "snap_" + (crc32 & 0xFFFF);
|
||||
return Long.toString(crc32);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import static org.junit.Assert.assertEquals;
|
|||
public class SignatureHelperTest {
|
||||
@Test
|
||||
public void test() {
|
||||
String url = SignatureHelper.getUrl("rusEFI 2020.07.06.frankenso_na6.2468827536").first;
|
||||
assertEquals("https://rusefi.com/online/ini/rusefi/2020/07/06/frankenso_na6/2468827536.ini", url);
|
||||
String url = SignatureHelper.getUrl("rusEFI master.2020.07.06.frankenso_na6.2468827536").first;
|
||||
assertEquals("https://rusefi.com/online/ini/rusefi/master/2020/07/06/frankenso_na6/2468827536.ini", url);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue