Skip to content

Commit e0a42a5

Browse files
authored
Ability to diff assemblies from files, directories, nuget and github (elastic#3027)
This commit adds a build target, diff, that can create a diff output of assemblies from 1. files 2. directories 3. nuget packages 4. github.amrom.workers.devmits It uses Progress/Telerik's JustAssembly command line tool to generate an XML file of the public diffs between two assemblies, with functions implemented to transform XML to markdown and asciidoc. Since JustAssembly installation cannot be easily automated, an exception is thrown when diff is run if the tool is not installed, prompting the user with a link to download. When specifying directories or nuget packages, the assemblies within the first path will be paired up with assemblies with the same name in the second path, and a diff will be generated for each pair. The diff can output XML, Markdown and Asciidoc, with the latter two implemented as functions that convert the XML to a document structure. Add skipdocs argument to be able to skip generating documentation.
1 parent 757373e commit e0a42a5

File tree

6 files changed

+471
-6
lines changed

6 files changed

+471
-6
lines changed

build/scripts/Commandline.fsx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Targets:
2828
* canary [apikey] [feed]
2929
- create a canary nuget package based on the current version if [feed] and [apikey] are provided
3030
also pushes to upstream (myget)
31+
* diff <github|nuget|dir|assembly> <version|path 1> <version|path 2> [format]
3132
3233
NOTE: both the `test` and `integrate` targets can be suffixed with `-all` to force the tests against all suported TFM's
3334
@@ -43,6 +44,7 @@ module Commandline =
4344
let private args = getBuildParamOrDefault "cmdline" "build" |> split ' '
4445

4546
let skipTests = args |> List.exists (fun x -> x = "skiptests")
47+
let skipDocs = args |> List.exists (fun x -> x = "skipdocs") || isMono
4648
let seed =
4749
match args |> List.tryFind (fun x -> x.StartsWith("seed:")) with
4850
| Some t -> t.Replace("seed:", "")
@@ -57,7 +59,7 @@ module Commandline =
5759
args
5860
|> List.filter (
5961
fun x ->
60-
x <> "skiptests" && x <> "source_serialization" && not (x.StartsWith("seed:")) && not (x.StartsWith("random:"))
62+
x <> "skiptests" && x <> "skipdocs" && x <> "source_serialization" && not (x.StartsWith("seed:")) && not (x.StartsWith("random:"))
6163
)
6264

6365
let multiTarget =
@@ -102,6 +104,24 @@ module Commandline =
102104
match Uri.TryCreate(candidate, UriKind.RelativeOrAbsolute) with
103105
| true, _ -> Some candidate
104106
| _ -> None
107+
108+
let private (|IsDiff|_|) (candidate:string) =
109+
let c = candidate |> toLower
110+
match c with
111+
| "github" | "nuget" | "directories" | "assemblies" -> Some c
112+
| _ -> failwith (sprintf "Unknown diff type: %s" candidate)
113+
114+
let private (|IsProject|_|) (candidate:string) =
115+
let c = candidate |> toLower
116+
match c with
117+
| "nest" | "elasticsearch.net" | "nest.jsonnetserializer" -> Some c
118+
| _ -> None
119+
120+
let private (|IsFormat|_|) (candidate:string) =
121+
let c = candidate |> toLower
122+
match c with
123+
| "xml" | "markdown" | "asciidoc" -> Some c
124+
| _ -> None
105125

106126
let parse () =
107127
setEnvironVar "FAKEBUILD" "1"
@@ -161,7 +181,28 @@ module Commandline =
161181
setBuildParam "esversions" esVersions
162182
setBuildParam "clusterfilter" "ConnectionReuse"
163183
setBuildParam "numberOfConnections" numberOfConnections
164-
184+
185+
| ["diff"; IsDiff diffType; IsProject project; firstVersionOrPath; secondVersionOrPath; IsFormat format] ->
186+
setBuildParam "diffType" diffType
187+
setBuildParam "project" project
188+
setBuildParam "first" firstVersionOrPath
189+
setBuildParam "second" secondVersionOrPath
190+
setBuildParam "format" format
191+
| ["diff"; IsDiff diffType; IsProject project; firstVersionOrPath; secondVersionOrPath] ->
192+
setBuildParam "diffType" diffType
193+
setBuildParam "project" project
194+
setBuildParam "first" firstVersionOrPath
195+
setBuildParam "second" secondVersionOrPath
196+
| ["diff"; IsDiff diffType; firstVersionOrPath; secondVersionOrPath; IsFormat format] ->
197+
setBuildParam "diffType" diffType
198+
setBuildParam "first" firstVersionOrPath
199+
setBuildParam "second" secondVersionOrPath
200+
setBuildParam "format" format
201+
| ["diff"; IsDiff diffType; firstVersionOrPath; secondVersionOrPath] ->
202+
setBuildParam "diffType" diffType
203+
setBuildParam "first" firstVersionOrPath
204+
setBuildParam "second" secondVersionOrPath
205+
165206
| ["temp"; ] -> ignore()
166207
| ["canary"; ] -> ignore()
167208
| ["canary"; apiKey ] ->

0 commit comments

Comments
 (0)