-
Notifications
You must be signed in to change notification settings - Fork 93
Работа с конфигом в формате JSON #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
69f7003
Исправление преобразования к булево, при не заданном параметре
khorevaa 5692abc
Пустные строчки
khorevaa 99a5bf0
Добавил обработку параметра при пакетной синхронизации
khorevaa 3f348ca
Конфигурация в JSON для команды sync -all
khorevaa e6428f4
Немного справки
khorevaa f629d15
еше справка
khorevaa 52252d6
merge develop
khorevaa 0808da9
Много изменений по замечаниям.
khorevaa 6be879a
Убрал вырезку комментариев. Поправил зависимость
khorevaa 17a4781
Упростил код. согласно ревью.
khorevaa b7eab06
Повымил версию требуемого движка oscript
khorevaa 7f61cfe
Изменение на фиксированное соответсвие.
khorevaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"gitsync-options": | ||
{ | ||
"global": | ||
{ | ||
"email-domain": "server.com", | ||
"v8-version": "8.3.10", | ||
"git-executable": "git" | ||
} | ||
}, | ||
"repositories" : [ | ||
{ | ||
"name" : "test", | ||
"git-local-path": "Путь", | ||
"git-remote": "адрес2", | ||
"v8-storage-dir": "каталог2", | ||
"process-fatform-modules": "on", | ||
"push-every-n-commits": 5, | ||
"auto-set-tags": "on", | ||
"stop-if-empty-comment": "on", | ||
"check-authors": "on" | ||
//"email-domain", | ||
//"v8-version", | ||
//"git-executable", | ||
}, | ||
{ | ||
"name" : "test2", | ||
"git-local-path": "Путь2", | ||
"git-remote": "адрес2", | ||
"v8-storage-dir": "каталог2", | ||
"process-fatform-modules": "on", | ||
"push-every-n-commits": 5, | ||
"auto-set-tags": "on", | ||
"stop-if-empty-comment": "on", | ||
"check-authors": "on" | ||
//"email-domain", | ||
//"v8-version", | ||
//"git-executable", | ||
|
||
} | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
| ||
#Использовать json | ||
|
||
Перем мНастройки; | ||
Перем СоответствиеКлючамИПараметра; | ||
|
||
Процедура ПриСозданииОбъекта(ВходящиеСоответствиеКлючамИПараметра) | ||
|
||
СоответствиеКлючамИПараметра = ВходящиеСоответствиеКлючамИПараметра; | ||
|
||
КонецПроцедуры | ||
|
||
Функция ПрочитатьФайл(Знач ИмяФайла) | ||
ФайлСуществующий = Новый Файл(ИмяФайла); | ||
Если Не ФайлСуществующий.Существует() Тогда | ||
ВызватьИсключение "Неверная структура файла настроек / файл пустой";; | ||
КонецЕсли; | ||
|
||
Чтение = Новый ЧтениеТекста(ИмяФайла, КодировкаТекста.UTF8); | ||
Рез = Чтение.Прочитать(); | ||
Чтение.Закрыть(); | ||
Возврат Рез; | ||
КонецФункции // ПрочитатьФайл() | ||
|
||
Функция ПрочитатьНастройкиИзФайла(Знач ФайлНастроек) Экспорт | ||
|
||
мНастройки = Новый Структура; | ||
|
||
JsonСтрока = ПрочитатьФайл(ФайлНастроек); | ||
|
||
ПарсерJSON = Новый ПарсерJSON(); | ||
ПараметрыJSON = ПарсерJSON.ПрочитатьJSON(JsonСтрока); | ||
|
||
ВсеНастройки = ПараметрыJSON["gitsync-options"]; | ||
ГлобальныеНастройки = ВсеНастройки["global"]; | ||
|
||
Для Каждого КлючИЗначение Из ГлобальныеНастройки Цикл | ||
Ключ = СоответствиеКлючамИПараметра[КлючИЗначение.Ключ]; | ||
|
||
Если НЕ Ключ = Неопределено Тогда | ||
мНастройки.Вставить(Ключ, КлючИЗначение.Значение); | ||
КонецЕсли; | ||
|
||
КонецЦикла; | ||
|
||
мНастройки.Вставить("Репозитарии", Новый Массив); | ||
|
||
МассивРепозиториев = ВсеНастройки["repositories"]; | ||
|
||
Для Каждого Репозиторий Из МассивРепозиториев Цикл | ||
|
||
ПрочитатьНастройкиРепозитория(Репозиторий); | ||
|
||
КонецЦикла; | ||
|
||
Возврат мНастройки; | ||
|
||
КонецФункции | ||
|
||
Процедура ПрочитатьНастройкиРепозитория(Знач СтруктураНастроекРепозитория ) | ||
|
||
Репо = Новый Структура; | ||
|
||
мНастройки.Репозитарии.Добавить(Репо); | ||
|
||
Для Каждого КлючИЗначение Из СтруктураНастроекРепозитория Цикл | ||
|
||
Ключ = СоответствиеКлючамИПараметра[КлючИЗначение.Ключ]; | ||
|
||
Если НЕ Ключ = Неопределено Тогда | ||
Репо.Вставить(Ключ, КлючИЗначение.Значение); | ||
КонецЕсли; | ||
|
||
КонецЦикла; | ||
|
||
Для Каждого ГлобальнаяНастройка Из мНастройки Цикл | ||
|
||
Ключ = ГлобальнаяНастройка.Ключ; | ||
|
||
Если ГлобальнаяНастройка.Ключ = "Репозитарии" Тогда | ||
Продолжить | ||
КонецЕсли; | ||
|
||
ЕстьСвояНастройка = Репо.Свойство(Ключ); | ||
|
||
Если НЕ ЕстьСвояНастройка | ||
ИЛИ ЕстьСвояНастройка и ПустаяСтрока(Репо[Ключ]) Тогда | ||
|
||
Репо.Вставить(Ключ, ГлобальнаяНастройка.Значение); | ||
КонецЕсли; | ||
|
||
КонецЦикла | ||
|
||
КонецПроцедуры | ||
|
||
Функция СтрокаНекорректнаяСтруктураНастроек() | ||
Возврат "Некорректная структура файла настроек"; | ||
КонецФункции |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше возврать ФиксированноеСоответствие, так будет гарантия, что никто случайно не поменяет коллекцию
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да поменяю..