{"action":"created","issue":{"url":"https://api.github.com/repos/KSP-CKAN/CKAN/issues/1321","labels_url":"https://api.github.com/repos/KSP-CKAN/CKAN/issues/1321/labels{/name}","comments_url":"https://api.github.com/repos/KSP-CKAN/CKAN/issues/1321/comments","events_url":"https://api.github.com/repos/KSP-CKAN/CKAN/issues/1321/events","html_url":"https://github.com/KSP-CKAN/CKAN/pull/1321","id":95854431,"number":1321,"title":"Version Edit Transformer","user":{"login":"dbent","id":1547727,"avatar_url":"https://avatars.githubusercontent.com/u/1547727?v=3","gravatar_id":"","url":"https://api.github.com/users/dbent","html_url":"https://github.com/dbent","followers_url":"https://api.github.com/users/dbent/followers","following_url":"https://api.github.com/users/dbent/following{/other_user}","gists_url":"https://api.github.com/users/dbent/gists{/gist_id}","starred_url":"https://api.github.com/users/dbent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbent/subscriptions","organizations_url":"https://api.github.com/users/dbent/orgs","repos_url":"https://api.github.com/users/dbent/repos","events_url":"https://api.github.com/users/dbent/events{/privacy}","received_events_url":"https://api.github.com/users/dbent/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/KSP-CKAN/CKAN/labels/pull%20request","name":"pull request","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-07-18T19:47:35Z","updated_at":"2015-07-20T14:55:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/KSP-CKAN/CKAN/pulls/1321","html_url":"https://github.com/KSP-CKAN/CKAN/pull/1321","diff_url":"https://github.com/KSP-CKAN/CKAN/pull/1321.diff","patch_url":"https://github.com/KSP-CKAN/CKAN/pull/1321.patch"},"body":"Spun-off of #1320 from @plague006.\r\n\r\nThis adds a new `ITransformer`, `VersionEditTransformer`, that uses regexes (there's no problem that can't be solved with more regexes) to allow simple editing of version strings.\r\n\r\nThe full example is:\r\n\r\n```json\r\n{\r\n    \"spec_version\": 1,\r\n    \"identifier\": \"AwesomeMod\",\r\n    \"x_netkan_version_edit\": {\r\n        \"find\": \"^[vV]?(?<version>.+)$\",\r\n        \"replace\": \"${version}\",\r\n        \"strict\": true\r\n    }\r\n}\r\n```\r\n\r\n`find` is a standard .NET regular expression. `replace` is a .NET regular expression [substitution string](https://msdn.microsoft.com/en-us/library/ewy2t5e0%28v=vs.110%29.aspx).\r\n\r\nWhat the example says is \"The version string may start with an uppercase or lowercase `v`, in which case edit the version to be just whatever proceeds the `v`\". `strict` toggles whether or not the transformer should throw an exception if `find` fails to match on the version string.\r\n\r\nThe default value of `replace` is `${version}`. The default value of `strict` is `true`. Therefore the above example can be simplified to:\r\n\r\n```json\r\n{\r\n    \"spec_version\": 1,\r\n    \"identifier\": \"AwesomeMod\",\r\n    \"x_netkan_version_edit\": {\r\n        \"find\": \"^[vV]?(?<version>.+)$\"\r\n    }\r\n}\r\n```\r\n\r\nIf `x_netkan_version_edit` is a string instead of an object, its value is treated as the value of `find`. Therefore the example can be simplified down to:\r\n\r\n```json\r\n{\r\n    \"spec_version\": 1,\r\n    \"identifier\": \"AwesomeMod\",\r\n    \"x_netkan_version_edit\": \"^[vV]?(?<version>.+)$\"\r\n}\r\n```\r\n\r\nBecause we're using full regular expressions and substitution strings, we can come up with all sorts of wacky subs:\r\n\r\n```json\r\n{\r\n    \"spec_version\": 1,\r\n    \"identifier\": \"AwesomeMod\",\r\n    \"version\": \"1.2.3\",\r\n    \"x_netkan_version_edit\": {\r\n        \"find\": \"^(?<major>\\\\d+)\\\\.(?<minor>\\\\d+)\\\\.(?<patch>\\\\d+)$\",\r\n        \"replace\": \"${patch}.${minor}.${major}\"\r\n    }\r\n}\r\n```\r\n\r\nwould produce:\r\n\r\n\r\n```json\r\n{\r\n    \"spec_version\": 1,\r\n    \"identifier\": \"AwesomeMod\",\r\n    \"version\": \"3.2.1\"\r\n}\r\n```\r\n\r\nMy recommendation is that we use this to strip wacky version strings down to their basic value, so we don't have to deal with leading-Vs (or lack thereof), code names in version strings, stability identifiers (alpha, beta), KSP version identifiers, or anything else. Using this would very likely lead to an epoch bump for the mod."},"comment":{"url":"https://api.github.com/repos/KSP-CKAN/CKAN/issues/comments/122910379","html_url":"https://github.com/KSP-CKAN/CKAN/pull/1321#issuecomment-122910379","issue_url":"https://api.github.com/repos/KSP-CKAN/CKAN/issues/1321","id":122910379,"user":{"login":"techman83","id":3467784,"avatar_url":"https://avatars.githubusercontent.com/u/3467784?v=3","gravatar_id":"","url":"https://api.github.com/users/techman83","html_url":"https://github.com/techman83","followers_url":"https://api.github.com/users/techman83/followers","following_url":"https://api.github.com/users/techman83/following{/other_user}","gists_url":"https://api.github.com/users/techman83/gists{/gist_id}","starred_url":"https://api.github.com/users/techman83/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techman83/subscriptions","organizations_url":"https://api.github.com/users/techman83/orgs","repos_url":"https://api.github.com/users/techman83/repos","events_url":"https://api.github.com/users/techman83/events{/privacy}","received_events_url":"https://api.github.com/users/techman83/received_events","type":"User","site_admin":false},"created_at":"2015-07-20T14:55:48Z","updated_at":"2015-07-20T14:55:48Z","body":":+1:  awesome"}}