Fixes #77 Makes --keep-version-file work for Azure and Vanilla (#78)

* initial keep file version working, will do more tests

* Update .gitignore

* Get latest tests to work

* ChangeLog
This commit is contained in:
iscai-msft 2019-05-21 15:57:24 -07:00 коммит произвёл Laurent Mazuel
Родитель cf7fb11885
Коммит 765ffb48a3
5 изменённых файлов: 19 добавлений и 5 удалений

2
.gitignore поставляемый
Просмотреть файл

@ -302,4 +302,4 @@ package/
*.tgz *.tgz
src/obj/ src/obj/
*.log *.log
.pytest_cache .pytest_cache

Просмотреть файл

@ -1,5 +1,8 @@
# Change Log # Change Log
### 2019-05-21 - 4.0.70
- Beta version of --keep-version-file for ARM generator
### 2019-02-13 - 4.0.67 ### 2019-02-13 - 4.0.67

Просмотреть файл

@ -7,6 +7,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using AutoRest.Core.Model; using AutoRest.Core.Model;
using AutoRest.Core;
using AutoRest.Extensions.Azure; using AutoRest.Extensions.Azure;
using AutoRest.Python.Model; using AutoRest.Python.Model;
using AutoRest.Python.Azure.Model; using AutoRest.Python.Azure.Model;
@ -72,8 +73,18 @@ namespace AutoRest.Python.Azure
await Write(serviceClientTemplateOpAsync, Path.Combine(folderName, "aio", "operations_async", "_" + codeModel.Name.ToPythonCase() + "_operations_async.py")); await Write(serviceClientTemplateOpAsync, Path.Combine(folderName, "aio", "operations_async", "_" + codeModel.Name.ToPythonCase() + "_operations_async.py"));
} }
var versionTemplate = new VersionTemplate { Model = codeModel, }; // do we need to write out the version template file?
await Write(versionTemplate, Path.Combine(folderName, "version.py")); var versionPath = Path.Combine(folderName, "version.py");
// protect the version file
await Settings.Instance.Host.ProtectFiles(versionPath);
if( true != await Settings.Instance.Host.GetValue<bool?>("keep-version-file") || string.IsNullOrEmpty(await Settings.Instance.Host.ReadFile(versionPath)) ) {
var versionTemplate = new VersionTemplate { Model = codeModel };
// if they didn't say to keep the old file (or it was not there/empty), write it out.
await Write(versionTemplate, versionPath);
}
//Models //Models
var models = codeModel.ModelTemplateModels.Where(each => !each.Extensions.ContainsKey(AzureExtensions.ExternalExtension)); var models = codeModel.ModelTemplateModels.Where(each => !each.Extensions.ContainsKey(AzureExtensions.ExternalExtension));

Просмотреть файл

@ -1247,7 +1247,7 @@ class HeaderOperations:
if raw: if raw:
client_raw_response = ClientRawResponse(None, response) client_raw_response = ClientRawResponse(None, response)
client_raw_response.add_headers({ client_raw_response.add_headers({
'value': models.GreyscaleColors, 'value': 'str',
}) })
return client_raw_response return client_raw_response
response_enum.metadata = {'url': '/header/response/prim/enum'} response_enum.metadata = {'url': '/header/response/prim/enum'}

Просмотреть файл

@ -1247,7 +1247,7 @@ class HeaderOperations(object):
if raw: if raw:
client_raw_response = ClientRawResponse(None, response) client_raw_response = ClientRawResponse(None, response)
client_raw_response.add_headers({ client_raw_response.add_headers({
'value': models.GreyscaleColors, 'value': 'str',
}) })
return client_raw_response return client_raw_response
response_enum.metadata = {'url': '/header/response/prim/enum'} response_enum.metadata = {'url': '/header/response/prim/enum'}