package Ġcom . form . coverage . diff Ċ Ċ import Ġcom . form . coverage . config . Diff Source Config Ċ import Ġcom . form . coverage . diff . git . J git Diff Ċ import Ġjava . io . File Ċ import Ġjava . net . URL Ċ Ċ const Ġval ĠDEFAULT _ PATCH _ FILE _ NAME : ĠString Ġ= Ġ" diff . patch " Ċ Ċ interface ĠDiff Source Ġ{ ĊĊĠĠĠ Ġval Ġsource Description : ĠString ĊĠĠĠ Ġfun Ġpull Diff (): ĠList < String > ĊĠĠĠ Ġfun Ġsave Diff To ( dir : ĠFile ): ĠFile Ċ } Ċ Ċ internal Ġclass ĠFile Diff Source ( ĊĠĠĠ Ġprivate Ġval ĠfilePath : ĠString Ċ ) Ġ: ĠDiff Source Ġ{ ĊĊĠĠĠ Ġoverride Ġval Ġsource Description Ġ= Ġ" File : Ġ$ filePath " ĊĊĠĠĠ Ġoverride Ġfun Ġpull Diff (): ĠList < String > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġfile Ġ= ĠFile ( filePath ) ĊĠĠĠĠĠĠĠ Ġreturn Ġif Ġ( file . exists () Ġ&& Ġfile . isFile ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfile . read Lines () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠRuntimeException ("' $ filePath ' Ġnot Ġa Ġfile Ġor Ġdoesn 't Ġexist ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsave Diff To ( dir : ĠFile ): ĠFile Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠFile ( filePath ). copy To ( dir . resolve ( DEFAULT _ PATCH _ FILE _ NAME ), Ġtrue ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ internal Ġclass ĠUrl Diff Source ( ĊĠĠĠ Ġprivate Ġval Ġurl : ĠString Ċ ) Ġ: ĠDiff Source Ġ{ ĊĠĠĠ Ġoverride Ġval Ġsource Description Ġ= Ġ" URL : Ġ$ url " ĊĊĠĠĠ Ġprivate Ġval Ġdiff Content : ĠString Ġby Ġlazy Ġ{ ĠURL ( url ). read Text () Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġpull Diff (): ĠList < String > Ġ= Ġdiff Content . lines () ĊĊĠĠĠ Ġoverride Ġfun Ġsave Diff To ( dir : ĠFile ): ĠFile Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġdir . resolve ( DEFAULT _ PATCH _ FILE _ NAME ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwrite Text ( diff Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ internal Ġclass ĠGit Diff Source ( ĊĠĠĠ Ġprivate Ġval Ġproject Root : ĠFile , ĊĠĠĠ Ġprivate Ġval Ġcompare With : ĠString Ċ ) Ġ: ĠDiff Source Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġdiff Content : ĠString Ġby Ġlazy Ġ{ ĊĠĠĠĠĠĠĠ ĠJ git Diff ( project Root . resolve (". git ")). obtain ( compare With ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġval Ġsource Description Ġ= Ġ" Git : Ġdiff Ġ$ compare With " ĊĊĠĠĠ Ġoverride Ġfun Ġpull Diff (): ĠList < String > Ġ= Ġdiff Content . lines () ĊĊĠĠĠ Ġoverride Ġfun Ġsave Diff To ( dir : ĠFile ): ĠFile Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġdir . resolve ( DEFAULT _ PATCH _ FILE _ NAME ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwrite Text ( diff Content ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ internal Ġfun Ġdiff Source Factory ( ĊĠĠĠ Ġproject Root : ĠFile , ĊĠĠĠ Ġdiff Source Config : ĠDiff Source Config Ċ ): ĠDiff Source Ġ= Ġwhen Ġ{ ĊĊĠĠĠ Ġdiff Source Config . file . isNotBlank () Ġ&& Ġdiff Source Config . url . isNotBlank () Ġ-> Ġthrow ĠIllegalStateException ( ĊĠĠĠĠĠĠĠ Ġ" Expected Ġonly ĠGit Ġconfiguration Ġor Ġfile Ġor ĠURL Ġdiff Ġsource Ġmore Ġthan Ġone : Ġ" Ġ+ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" git . diff Base =${ diff Source Config . diff Base } Ġfile =${ diff Source Config . file }, Ġurl =${ diff Source Config . url }" ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġdiff Source Config . file . isNotBlank () Ġ-> ĠFile Diff Source ( diff Source Config . file ) ĊĠĠĠ Ġdiff Source Config . url . isNotBlank () Ġ-> ĠUrl Diff Source ( diff Source Config . url ) ĊĠĠĠ Ġdiff Source Config . diff Base . isNotBlank () Ġ-> ĠGit Diff Source ( project Root , Ġdiff Source Config . diff Base ) ĊĊĠĠĠ Ġelse Ġ-> Ġthrow ĠIllegalStateException (" Expected ĠGit Ġconfiguration Ġor Ġfile Ġor ĠURL Ġdiff Ġsource Ġbut Ġall Ġare Ġblank ") Ċ } Ċ