Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
matrix-stickers
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneurs
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Elliu
matrix-stickers
Validations
210d2b3a
Valider
210d2b3a
rédigé
17 août 2022
par
Elliu
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
WIP: kinda working
parent
53149a63
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
stpkg
+36
-42
36 ajouts, 42 suppressions
stpkg
avec
36 ajouts
et
42 suppressions
stpkg
+
36
−
42
Voir le fichier @
210d2b3a
...
...
@@ -175,7 +175,7 @@ file_get_height() {
file_get_type
()
{
xdg-mime query filetype
"
$1
"
;
}
file_get_ext
()
{
xdg-mime query filetype
"
$1
"
|
sed
's+^.*/++'
;
}
file_get_ext_from_type
()
{
echo
"
$1
"
|
sed
's+^.*/++'
;
}
file_get_name
()
{
echo
"
$1
"
|
cut
-f1
-d
'.'
;
}
file_get_name
()
{
echo
-n
"
$1
"
|
cut
-f1
-d
'.'
;
}
__upload_file
()
{
local
TYPE
=
$1
# The type of file (png/gif)
...
...
@@ -225,7 +225,7 @@ create_sticker_json() {
local
TYPE
=
$5
# The type of the picture (png/gif)
local
MXC
=
$6
# The MXC URL
echo
-n
"{
\"
body
\"
:
\"
$NAME
\"
,
\"
info
\"
:{
\"
mimetype
\"
:
\"
image/
$TYPE
\"
,
\"
h
\"
:
$HEIGHT
,"
\
echo
-n
"{
\"
body
\"
:
\"
$NAME
\"
,
\"
info
\"
:{
\"
mimetype
\"
:
\"
$TYPE
\"
,
\"
h
\"
:
$HEIGHT
,"
\
"
\"
w
\"
:
$WIDTH
,
\"
thumbnail_url
\"
:
\"
$MXC
\"
},
\"
msgtype
\"
:
\"
m.sticker
\"
,
\"
url
\"
:
\"
$MXC
\"
"
\
",
\"
id
\"
:
\"
$PACK_NAME
-
$NAME
\"
}"
}
...
...
@@ -788,7 +788,8 @@ __pack() {
[
!
-f
$DEST_INDEX
]
&&
die
"Failed to create the index file '
$DEST_INDEX
'"
# Populate all stickers
echo
-n
"{
\"
title
\"
:
\"
$PACK_NAME
\"
,
\"
id
\"
:
\"
`
uuidgen
`
\"
,
\"
stickers
\"
:["
>
$DEST_INDEX
local
TEMP_JSON
=
`
mktemp
--suffix
=
.stpkg
`
echo
-n
"{
\"
title
\"
:
\"
$PACK_NAME
\"
,
\"
id
\"
:
\"
`
uuidgen
`
\"
,
\"
stickers
\"
:["
>
$TEMP_JSON
cd
$PACK_FOLDER
local
TOTAL_FILES
=
`
find
.
-maxdepth
1
-type
f |
wc
-l
`
...
...
@@ -826,55 +827,48 @@ __pack() {
skipFiles[
$i
]=
""
done
local
ST_JSON
=
""
for
FILE
in
*
;
do
# Add a ',' only if it's not the first in the array
echo
-n
"
$FIRST_IN_ARRAY
"
>>
$DEST_INDEX
echo
-n
"
$FIRST_IN_ARRAY
"
>>
$TEMP_JSON
local
STICKER_STATUS
=
""
local
STICKER_NAME
=
$(
file_get_name
"
$FILE
"
)
if
[[
-v
skipFiles[
$FILE
]
]]
;
then continue
;
fi
if
[[
-v
unchangedFiles[
$FILE
]
]]
;
then
STICKER_STATUS
=
"Unchanged"
ST_JSON
=
`
jq
".stickers[] | select(.body ==
\"
$STICKER_NAME
\"
)"
<
"
$DEST_INDEX
"
`
echo
"Processing new file
$FILE
"
elif
[[
-v
deletedFiles[
$FILE
]
]]
;
then
STICKER_STATUS
=
"Deleted"
ST_JSON
=
`
jq
".stickers[] | select(.body ==
\"
$STICKER_NAME
\"
)"
<
"
$DEST_INDEX
"
`
#TODO: remove checksum
#TODO: Don't print ","
if
[[
"
`
md5sum
$FILE
|
sed
-e
's/\([0-9a-f]\{32\}\) .*$/\1/'
`
"
=
"
`
cat
$SUM_FILE
|
grep
"
$FILE
"
|
sed
-e
's/\([0-9a-f]\{32\}\) .*$/\1/'
`
"
]]
;
then
else
if
[[
-v
updatedFiles[
$FILE
]
]]
;
then
STICKER_STATUS
=
"Updated"
#TODO: deleted old checksum
else
STICKER_STATUS
=
"New"
if
[[
"
`
md5sum
$FILE
|
sed
-e
's/\([0-9a-f]\{32\}\) .*$/\1/'
`
"
=
"
$(
cat
$SUM_FILE
|
grep
"
$FILE
"
|
sed
-e
's/\([0-9a-f]\{32\}\) .*$/\1/'
)
"
]]
;
then
die
"New file is replacing existing file, that should not be happening"
fi
fi
local
ST_JSON
=
""
process_sticker_file
$FILE
ST_JSON
$SUM_FILE
echo
"
$ST_JSON
"
>>
$DEST_INDEX
# For the report
[
"x
$FIRST_IN_ARRAY
"
=
"x"
]
&&
echo
-e
"StickerName MXC Type Width Height"
FIRST_IN_ARRAY
=
","
echo
-e
"
$ST_JSON
"
| jq
-r
'[.body, .url, .info.mimetype, .info.w, .info.h]|join(" ")'
process_sticker_file
$FILE
ST_JSON
md5sum
$FILE
>>
$SUM_FILE
fi
progress_reset
done
| column
-t
for
FILE
in
"
${
!unchangedFiles[@]
}
"
;
do
echo
-n
"
$FIRST_IN_ARRAY
"
>>
$DEST_INDEX
[
"x
$FIRST_IN_ARRAY
"
=
"x"
]
&&
echo
-e
"StickerName MXC Type Width Height"
FIRST_IN_ARRAY
=
","
#echo -e "$ST_JSON" | jq -r '[.body, .url, .info.mimetype, .info.w, .info.h]|join(" ")'
echo
"
$FILE
unchanged"
done
| column
-t
echo
"
$ST_JSON
"
>>
"
$TEMP_JSON
"
for
FILE
in
"
${
!updatedFiles[@]
}
"
;
do
echo
-n
"
$FIRST_IN_ARRAY
"
>>
$DEST_INDEX
[
"x
$FIRST_IN_ARRAY
"
=
"x"
]
&&
echo
-e
"StickerName MXC Type Width Height"
# For the report
[
"x
$FIRST_IN_ARRAY
"
=
"x"
]
&&
echo
-e
"StickerName MXC Type Width Height Status"
FIRST_IN_ARRAY
=
","
echo
"
$FILE
updated
"
done
| column
-t
local
report
=
"
`
echo
-ne
"
$ST_JSON
"
| jq
-r
'[.body, .url, .info.mimetype, .info.w, .info.h]|join(" ")'
`
$STICKER_STATUS
"
echo
"
$report
"
for
FILE
in
"
${
!deletedFiles[@]
}
"
;
do
echo
-n
"
$FIRST_IN_ARRAY
"
>>
$DEST_INDEX
[
"x
$FIRST_IN_ARRAY
"
=
"x"
]
&&
echo
-e
"StickerName MXC Type Width Height"
FIRST_IN_ARRAY
=
","
#echo -e "$ST_JSON" | jq -r '[.body, .url, .info.mimetype, .info.w, .info.h]|join(" ")'
echo
"
$FILE
deleted, but kept in the pack"
progress_reset
done
| column
-t
# Update the sum file:
# Keep deleted but kept
# Remove deleted and deleted
...
...
@@ -888,9 +882,9 @@ __pack() {
echo
-ne
"#
$PACK_NAME
\n
(no preview)"
>
"
$DEST_FOLDER
/README.md"
find
$DEST_FOLDER
-type
f
\(
!
-name
"preview.png"
-and
!
-name
"
$PACK_NAME
.json"
-and
!
-name
'.*.checksums'
\)
-exec
rm
{}
\;
echo
-n
"]}"
>>
$
DEST_INDEX
cat
$DEST_INDEX
cat
$DEST_INDEX
| jq | sponge
$DEST_INDEX
echo
-n
"]}"
>>
$
TEMP_JSON
cat
$TEMP_JSON
| jq
>
$DEST_INDEX
echo
$TEMP_JSON
info
"Pack created, you can now commit it and create a MR to share it with other users"
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter