// ĠCopyright Ġ 2 0 0 0 - 2 0 1 8 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġorg . jetbrains . plugins . github . pull request . data Ċ Ċ import Ġcom . intellij . openapi . Disposable Ċ import Ġcom . intellij . openapi . progress . Progress Manager Ċ import Ġcom . intellij . openapi . util . Co uple Ċ import Ġcom . intellij . util . EventDispatcher Ċ import Ġgit 4 idea . commands . Git Ċ import Ġgit 4 idea . repo . Git Remote Ċ import Ġgit 4 idea . repo . Git Repository Ċ import Ġorg . jetbrains . annotations . Called In A wt Ċ import Ġorg . jetbrains . plugins . github . api . data . Github PullRequest Detailed Ċ import Ġjava . util .* Ċ import Ġjava . util . concurrent . Future Ċ import Ġkotlin . properties . Deleg ates Ċ Ċ class ĠGithub Pull Requests Branches Fetcher ( progress Manager : ĠProgress Manager , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġgit : ĠGit , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġdetails Loader : ĠGithub Pull Requests Details Loader , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġrepository : ĠGit Repository , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprivate Ġval Ġremote : ĠGit Remote ) ĊĠ Ġ: ĠSingle Worker Process Executor ( progress Manager , Ġ" GitHub ĠPR Ġbranch Ġfetching Ġbreak er "), ĊĠĠĠ ĠGithub Pull Requests Details Loader . Request Changed Listener Ġ{ ĊĊĠ Ġ@ set : Called In A wt ĊĠ Ġvar Ġrequest : ĠFuture < Co uple < String >> ? Ġby ĠDeleg ates . observable < Future < Co uple < String >> ? >( null ) Ġ{ Ġ_, Ġ_, Ġ_ Ġ-> ĊĠĠĠ Ġchange EventDispatcher . mult ic aster . request Changed () ĊĠ Ġ} ĊĠĠĠ Ġprivate Ġset ĊĊĠ Ġprivate Ġval Ġchange EventDispatcher Ġ= ĠEvent Dispatcher . create ( Request Changed Listener :: class . java ) ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġdetails Loader . add Request ChangeListener ( this , Ġthis ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġrequest Changed () Ġ{ ĊĠĠĠ Ġcancel Current Tasks () ĊĠĠĠ Ġrequest Ġ= Ġdetails Loader . request ?. let Ġ{ Ġdetails Ġ-> ĊĠĠĠĠĠ Ġsubmit Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpull Request Ġ= Ġdetails . get () ĊĠĠĠĠĠĠĠ Ġfetch Branch ( pull Request ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġfetch Branch ( details : ĠGithub PullRequest Detailed ): ĠCo uple < String > Ġ{ ĊĠĠĠ Ġif Ġ(! is Commit F etched ( details . head . sha )) Ġ{ ĊĠĠĠĠĠ Ġgit . fetch ( repository , Ġremote , Ġempty List (), Ġ" refs / pull /${ details . number }/ head : "). throw OnError () ĊĠĠĠ Ġ} ĊĠĠĠ Ġif Ġ(! is Commit F etched ( details . head . sha )) Ġthrow ĠIllegalStateException (" Pull Ġrequest Ġhead Ġis Ġnot Ġavailable Ġafter Ġfetch ") ĊĠĠĠ Ġreturn ĠCo uple . of ( details . base . sha , Ġdetails . head . sha ) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġis Commit F etched ( commit Hash : ĠString ): ĠBoolean Ġ{ ĊĠĠĠ Ġval Ġresult Ġ= Ġgit . get ObjectType ( repository , Ġcommit Hash ) ĊĠĠĠ Ġreturn Ġresult . success () Ġ&& Ġresult . output As Joined String Ġ== Ġ" commit " ĊĠ Ġ} ĊĊĠ Ġfun Ġadd Branch ChangeListener ( listener : ĠRequest Changed Listener , Ġdis posable : ĠDis posable ) Ġ= ĊĠĠĠ Ġchange EventDispatcher . addListener ( listener , Ġdis posable ) ĊĊĠ Ġinterface ĠRequest Changed Listener Ġ: ĠEvent Listener Ġ{ ĊĠĠĠ Ġfun Ġrequest Changed () ĊĠ Ġ} Ċ } Ċ