├── LICENSE ├── README.md └── cache └── cls └── Studio └── SourceControl ├── Command └── GITClient.xml ├── GIT.xml ├── Sample └── Callback.xml └── Util └── Logger.xml /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 InterSystems Iberia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Git Plugin for Studio 2 | [InterSystems Caché](http://www.intersystems.com/our-products/cache/cache-overview/) Studio plugin to use Git. 3 | 4 | ## Requirements 5 | * [Git SCM](https://git-scm.com/downloads). 6 | 7 | ## Installation 8 | * Clone repository or just download latest version into a local directory 9 | ``` 10 | git clone https://github.com/intersystems-ib/cache-git-studio.git 11 | ``` 12 | 13 | * Open a Terminal session in Cache 14 | * Switch to a namespace where you want to use Git source control 15 | ``` 16 | zn "ENSEMBLE" 17 | ``` 18 | 19 | * Load and compile the downloaded source code 20 | ``` 21 | set path="C:\Temp\cache-iat-pubsub\cache" 22 | do $system.OBJ.ImportDir(path,"*.xml","ck",.error,1) 23 | ``` 24 | 25 | ## Setup 26 | Configure *cache-git-studio* using `^GITConfig` global. 27 | 28 | ### Windows example 29 | ``` 30 | // path to git binaries 31 | set ^GITConfig($username,"gitpath")="C:\Users\MyUser\AppData\Local\Programs\Git\bin\" 32 | 33 | // path to git work directory 34 | set ^GITConfig($username,"workdir")="c:\sandbox\MyApp\" 35 | 36 | // [optional] author name used in git commits 37 | set ^GITConfig($username,"authorname")="John Doe" 38 | 39 | // [optional] author email used in git commits 40 | set ^GITConfig($username,"authoremail")="johndoe@server.com" 41 | 42 | // temp. file to store git output 43 | set ^GITConfig($username,"output")="c:\git.output.txt" 44 | 45 | // temp. file to store git errors 46 | set ^GITConfig($username,"error")="c:\git.error.txt" 47 | 48 | // [optional] use UDL format instead of XML (default) 49 | set ^GITConfig($username,"udl")="1" 50 | 51 | // [optional] use xml as file extension always. 52 | // when using UDL you may want to turn this off (0) so extensions will be like: cls, mac, etc. 53 | set ^GITConfig($username,"xmlextension")="0" 54 | 55 | // [optional] classmethod to call after reloading files 56 | set ^GITConfig($username,"on.reloadfiles")=$lb("Studio.SourceControl.Sample.Callback", "Change") 57 | 58 | // [optional] classmethod to call after a workdir load operation 59 | set ^GITConfig($username,"on.workdirload")=$lb("Studio.SourceControl.Sample.Callback", "Change") 60 | 61 | // [optional] classmethod to call after a pull operation 62 | set ^GITConfig($username,"on.pull")=$lb("Studio.SourceControl.Sample.Callback", "Change") 63 | ``` 64 | 65 | ### Linux example 66 | ``` 67 | // path to git binaries 68 | set ^GITConfig($username,"gitpath")="/usr/local/git/bin/" 69 | 70 | // path to git work directory 71 | set ^GITConfig($username,"workdir")="/workspace/myuser/myrepo/" 72 | 73 | // path to home directory 74 | set ^GITConfig($username,"homedir")="/home/ensemble" 75 | 76 | // [optional] author name used in git commits 77 | set ^GITConfig($username,"authorname")="John Doe" 78 | 79 | // [optional] author email used in git commits 80 | set ^GITConfig($username,"authoremail")="johndoe@server.com" 81 | 82 | // temp. file to store git output 83 | set ^GITConfig($username,"output")="/tmp/output.txt" 84 | 85 | // temp. file to store git errors 86 | set ^GITConfig($username,"error")="/tmp/error.txt" 87 | 88 | // [optional] use UDL format instead of XML (default) 89 | set ^GITConfig($username,"udl")="1" 90 | 91 | // [optional] use xml as file extension always. 92 | // when using UDL you may want to turn this off (0) so extensions will be like: cls, mac, etc. 93 | set ^GITConfig($username,"xmlextension")="0" 94 | 95 | // [optional] classmethod to call after reloading files 96 | set ^GITConfig($username,"on.reloadfiles")=$lb("Studio.SourceControl.Sample.Callback", "Change") 97 | 98 | // [optional] classmethod to call after a workdir load operation 99 | set ^GITConfig($username,"on.workdirload")=$lb("Studio.SourceControl.Sample.Callback", "Change") 100 | 101 | // [optional] classmethod to call after a pull operation 102 | set ^GITConfig($username,"on.pull")=$lb("Studio.SourceControl.Sample.Callback", "Change") 103 | ``` 104 | 105 | Configure your namespace to use `Studio.SourceControl.GIT` as the source control class: 106 | * Management Portal > System Administration > Additional Settings > Source Control. 107 | * Select your namespace. 108 | * Select `Studio.SourceControl.GIT` as the source control class. 109 | 110 | ## Credentials management 111 | * `cache-git-studio` does not prompt for passwords in Caché Studio. 112 | * `cache-git-studio` does not provide any specific credentials management features. 113 | * If you need to perform password protected operations, it is needed that you configure your local installation to avoid git to prompt for any password. 114 | * You must protect the files where your passwords are stored (file permissions). 115 | 116 | ### Windows 117 | You can use the `_netrc` file of the effective O.S. user that run Caché processes to store your credentials. 118 | Example: `C:\Users\user1\_netrc` 119 | ``` 120 | machine git.company.com 121 | login user1 122 | password mypassword 123 | ``` 124 | 125 | ### Linux 126 | You can use [git-credential-store](https://git-scm.com/docs/git-credential-store). 127 | ``` 128 | git config credential.helper 'store --file=~/.git-credentials' 129 | ``` 130 | 131 | ## Shared environment 132 | Git is used generally in a non-shared environment, every developer has its own work environment. 133 | 134 | However, in some cases you could need to use `cache-git-studio` in a shared environment (same instance, same namespace, different Caché developers). 135 | 136 | In shared environments, a simple approach is: 137 | * Use different Caché users for each developer. 138 | 139 | * Use the same working directory for each developer, so source code will be exported/imported from the same shared location: 140 | ``` 141 | set ^GITConfig($username, "workdir")="/workspace/myproject/" 142 | ``` 143 | 144 | * Use different output and error temporary files for each developer: 145 | ``` 146 | set ^GITConfig($username,"output")="/tmp/git.output.jdoe" 147 | set ^GITConfig($username,"output")="/tmp/git.error.jdoe" 148 | ``` 149 | 150 | * Use a common git user for all developers: All git actions will be performed using the same git user but commits will have different authors. 151 | 152 | * Configure commit author for each developer: 153 | ``` 154 | ^GITConfig($username,"authoremail")="john.doe@company.com" 155 | ^GITConfig($username,"authorname")="jdoe" 156 | ``` 157 | -------------------------------------------------------------------------------- /cache/cls/Studio/SourceControl/Command/GITClient.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | Commands will be run as the Caché O.S. user
]]>
8 | %RegisteredObject 9 | 62896,40708.534159 10 | 11 | 12 | 13 | Name of the subdir that will hold Caché files in Git workdir 14 | cache/ 15 | 16 | 17 | 18 | 19 | Logger instance to display messages 20 | Studio.SourceControl.Util.Logger 21 | 22 | 23 | 24 | 25 | Path to GIT binaries (with trailing slash) 26 | %String 27 | 28 | 29 | 30 | 31 | 32 | Path to GIT work dir (with trailing slash) 33 | %String 34 | 35 | 36 | 37 | 38 | 39 | HOME path (Unix only). The value will be set as $HOME before executing git commands. 40 | %String 41 | 42 | 43 | 44 | 45 | 46 | Git Author name (used in commits). If set, it will be used in the GIT_AUTHOR_EMAIL env. variable 47 | %String 48 | 49 | 50 | 51 | 52 | 53 | Git Author email (used in commits). If set, it will be used in the GIT_AUTHOR_EMAIL env. variable 54 | %String 55 | 56 | 57 | 58 | 59 | 60 | Path to Cache files in GIT work dir (with trailing slash) 61 | %String 62 | 63 | 64 | 65 | 66 | Temporary file to store errors from commands 67 | %String 68 | 69 | 70 | 71 | 72 | Temporary file to store output from commands 73 | %String 74 | 75 | 76 | 77 | 78 | 79 | Constructor. Initializations 80 | pGitPath:%String,pWorkDir:%String,pHomeDir:%String,pAuthorName:%String,pAuthorEmail:%String,pOutput:%String,pError:%String 81 | %Status 82 | 98 | 99 | 100 | 101 | 102 | 103 | git add 104 | 105 | %Status 106 | 114 | 115 | 116 | 117 | 118 | 119 | git commit 120 | 121 | %Status 122 | 127 | 128 | 129 | 130 | 131 | 132 | git status 133 | 134 | %Status 135 | 172 | 173 | 174 | 175 | 176 | 177 | git checkout 178 | 179 | %Status 180 | 188 | 189 | 190 | 191 | 192 | 193 | git log 194 | 195 | %Status 196 | 202 | 203 | 204 | 205 | 206 | 207 | git reset 208 | 209 | %Status 210 | 212 | 213 | 214 | 215 | 216 | 217 | git branch 218 | 219 | %Status 220 | 226 | 227 | 228 | 229 | 230 | 231 | git config --list 232 | 233 | %Status 234 | 236 | 237 | 238 | 239 | 240 | 241 | Returns a string with the name of the current branch 242 | %String 243 | 249 | 250 | 251 | 252 | 253 | 254 | current branch 255 | 256 | %Status 257 | 259 | 260 | 261 | 262 | 263 | 264 | git diff --name-status: useful to know what changes (status) have been done to files 265 | 266 | %Status 267 | 273 | 274 | 275 | 276 | 277 | 278 | git diff --stat: useful to report statistics about changes 279 | 280 | %Status 281 | 287 | 288 | 289 | 290 | 291 | 292 | git diff: simple changes made in a file 293 | 294 | %Status 295 | 299 | 300 | 301 | 302 | 303 | 304 | git push 305 | 306 | %Status 307 | 309 | 310 | 311 | 312 | 313 | 314 | git pull 315 | 316 | %Status 317 | 319 | 320 | 321 | 322 | 323 | 324 | git remote update group 325 | 326 | %Status 327 | 329 | 330 | 331 | 332 | 333 | 334 | git merge 335 | 336 | %Status 337 | 342 | 343 | 344 | 345 | 346 | 347 | git ls-files 348 | 349 | %Status 350 | 352 | 353 | 354 | 355 | 356 | 357 | Runs a cmd in the OS and returns the output and error 358 | 359 | 1 360 | %Status 361 | "_text) 397 | do ..Logger.Debug(cmd) 398 | 399 | set rc=$zf(-1,cmd_" 2> """_..ErrorFile_""" > """_..OutputFile_"""") 400 | 401 | set errorstream=##class(%FileCharacterStream).%New() 402 | set errorstream.Filename=..ErrorFile 403 | 404 | set outputstream=##class(%FileCharacterStream).%New() 405 | set outputstream.Filename=..OutputFile 406 | 407 | set ind=0 408 | if errorstream.Size>0 { 409 | do errorstream.Rewind() 410 | while 'errorstream.AtEnd { 411 | set errorLine=errorstream.Read() 412 | do ..Logger.Debug(errorLine) 413 | set ind=ind+1 414 | set pOutput(ind)=errorLine 415 | } 416 | } 417 | if outputstream.Size>0 { 418 | do outputstream.Rewind() 419 | while 'outputstream.AtEnd { 420 | set outputLine=outputstream.ReadLine() 421 | do ..Logger.Debug(outputLine) 422 | set ind=ind+1 423 | set pOutput(ind)=outputLine 424 | } 425 | } 426 | do errorstream.Clear(),outputstream.Clear() 427 | 428 | } catch errObj { 429 | set ret=errObj.AsStatus() 430 | } 431 | 432 | quit ret 433 | ]]> 434 | 435 |
436 |
437 | -------------------------------------------------------------------------------- /cache/cls/Studio/SourceControl/GIT.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Studio + Git Source Control 7 | Studio extension to provide Git source control integration
8 | See also Studio.SourceControl.Command.GITClient 9 |

Configuration

10 | 11 |

Windows Example

12 |
  13 | s ^GITConfig($username,"gitpath")="c:\SmartGitHg 4\git\bin\"  	// path to git binaries
  14 | s ^GITConfig($username,"workdir")="c:\sandbox\MyApp\"         	// path to git work directory
  15 | s ^GITConfig($username,"authorname")="John Doe"            	  	// [optional] author name used in git commits
  16 | s ^GITConfig($username,"authoremail")="johndoe@server.com"    	// [optional] author email used in git commits
  17 | s ^GITConfig($username,"output")="c:\git.output.txt"          	// temp. file to store git output
  18 | s ^GITConfig($username,"error")="c:\git.error.txt"            	// temp. file to store git error
  19 | s ^GITConfig($username,"udl")="1"            					// [optional] use UDL format instead of XML
  20 | s ^GITConfig($username,"xmlextension")="0"            			// [optional] use xml as file extension always. When using UDL you may want to turn this off.
  21 | s ^GITConfig($username,"on.reloadfiles")=$lb("Studio.SourceControl.Sample.Callback", "Change") 	// [optional] classmethod to call after reloading a file
  22 | s ^GITConfig($username,"on.workdirload")=$lb("Studio.SourceControl.Sample.Callback", "Change")	// [optional] classmethod to call after a workdir load operation
  23 | s ^GITConfig($username,"on.pull")=$lb("Studio.SourceControl.Sample.Callback", "Change") 		// [optional] classmethod to call after a pull operation
  24 | 
25 | 26 |

Linux example

27 |
  28 | s ^GITConfig($username,"gitpath")="/usr/local/git/bin/"       	// path to git binaries
  29 | s ^GITConfig($username,"workdir")="/workspace/myuser/myrepo/" 	// path to git work directory
  30 | s ^GITConfig($username,"homedir")="/home/ensemble"            	// path to git home directory
  31 | s ^GITConfig($username,"authorname")="John Doe"               	// [optional] author name used in git commits
  32 | s ^GITConfig($username,"authoremail")="johndoe@server.com"    	// [optional] author email used in git commits
  33 | s ^GITConfig($username,"output")="/tmp/output.txt"            	// temp. file to store git output
  34 | s ^GITConfig($username,"error")="/tmp/error.txt"              	// temp. file to store git error
  35 | s ^GITConfig($username,"udl")="1"            					// [optional] use UDL format instead of XML
  36 | s ^GITConfig($username,"xmlextension")="0"            			// [optional] use xml as file extension always. When using UDL you may want to turn this off.
  37 | s ^GITConfig($username,"on.reloadfiles")=$lb("Studio.SourceControl.Sample.Callback", "Change") 	// [optional] classmethod to call after reloading a file
  38 | s ^GITConfig($username,"on.workdirload")=$lb("Studio.SourceControl.Sample.Callback", "Change")	// [optional] classmethod to call after a workdir load operation
  39 | s ^GITConfig($username,"on.pull")=$lb("Studio.SourceControl.Sample.Callback", "Change") 		// [optional] classmethod to call after a pull operation
  40 | 
41 | 42 |

Changelog

43 |
    44 |
  • 0.1 - Simple initial version. Command outputs printed in Studio output
  • 45 |
  • 0.2 - Added HomeDir to GITClient to allow specifying a $HOME env. variable when running git commands
  • 46 |
  • 0.3 - Configuration by $username. Added AuthorName, AuthorEmail to allow specifiyng GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL in shared environments from Caché context
  • 47 |
  • 0.4 - Simplified source control git options: all options enabled. WorkdirLoadFiles now deletes files as well. Callbacks added.
  • 48 |
  • 0.5 - UDL format support added (Caché >= 2016.2)
  • 49 |
]]>
50 | %Studio.SourceControl.Base 51 | 62895,67330.802584 52 | 53 | 54 | 0.5 55 | 56 | 57 | 58 | 59 | First menu item that appears 60 | Add 61 | 62 | 63 | 64 | 65 | Not supported item types (or that you don't want to be exported/imported to/from git) 66 | PRJ,PKG 67 | 68 | 69 | 70 | 71 | Extensions that can not be exported as UDL. XML will always be used. 72 | $lb("hl7","dfi","lut") 73 | 74 | 75 | 76 | 77 | Logger instance to display messages 78 | Studio.SourceControl.Util.Logger 79 | 1 80 | 81 | 82 | 83 | 84 | GIT client wrapper 85 | Studio.SourceControl.Command.GITClient 86 | 1 87 | 88 | 89 | 90 | %Boolean 91 | 1 92 | 93 | 94 | 95 | %Boolean 96 | 1 97 | 98 | 99 | 100 | %Boolean 101 | 1 102 | 103 | 104 | 105 | %Boolean 106 | 1 107 | 108 | 109 | 110 | %List 111 | 1 112 | 113 | 114 | 115 | %List 116 | 1 117 | 118 | 119 | 120 | %List 121 | 1 122 | 123 | 124 | 125 | 126 | Export files in UDL format 127 | %Boolean 128 | 1 129 | 130 | 131 | 132 | 133 | Use always XML as filename extension 134 | %Boolean 135 | 1 136 | 137 | 138 | 139 | 140 | Studio menu options 141 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | ]]> 172 | 173 | 174 | 175 | 176 | 177 | Callback called on each menu item. Allows to enable/disable items 178 | 179 | %Status 180 | 225 | 226 | 227 | 228 | 229 | 230 | Handles user selected action from menu 231 | 232 | %Status 233 | 263 | 264 | 265 | 266 | 267 | 268 | Perfoms the selected action itself 269 | 270 | %Status 271 | local" quit ..Pull() 306 | if name="Push local->origin" quit ..Push() 307 | 308 | if name="Workdir - Load files" quit ..WorkdirLoadFiles(..Command.WorkDir) 309 | 310 | quit $$$OK 311 | ]]> 312 | 313 | 314 | 315 | 316 | 317 | Initialization. Load configuration and show status of work dir. 318 | Name:%String,Password:%String 319 | %Status 320 | GIT Source Control") 329 | 330 | set gitpath = $$$GetConfig("gitpath", "") 331 | set workdir = $$$GetConfig("workdir","") 332 | set homedir = $$$GetConfig("homedir","") 333 | set authorname = $$$GetConfig("authorname","") 334 | set authoremail = $$$GetConfig("authoremail","") 335 | set output = $$$GetConfig("output","") 336 | set error = $$$GetConfig("error","") 337 | set ..OnWorkDirLoad = $$$GetConfig("on.workdirload","") 338 | set ..OnPull = $$$GetConfig("on.pull","") 339 | set ..OnReloadFiles = $$$GetConfig("on.reloadfiles","") 340 | set ..UseUDL = $$$GetConfig("udl",0) 341 | set ..UseXMLExtension = $$$GetConfig("xmlextension",1) 342 | 343 | set ..Command = ##class(Studio.SourceControl.Command.GITClient).%New(gitpath, workdir, homedir, authorname, authoremail, output, error) 344 | do ..Logger.Info(">Working Directory: "_..Command.WorkDir) 345 | 346 | $$$THROWONERROR(sc,..Status("")) 347 | } catch errObj { 348 | set sc = errObj.AsStatus() 349 | do DecomposeStatus^%apiOBJ(sc,.err,"d") 350 | for i=1:1:err do ..Logger.Error(err(i)) 351 | 352 | set tError="Error while checking git status. GIT Source Control IS NOT initialized. Check your ^GITConfig global" 353 | set ret=$$$ERROR($$$GeneralError,tError) 354 | do ..Logger.Error(tError) 355 | } 356 | do ..Logger.Info("========================================================="_$char(13)) 357 | 358 | quit ret 359 | ]]> 360 | 361 | 362 | 363 | 364 | 365 | OnBeforeLoad. Loads source controlled files from external file 366 | InternalName:%String 367 | %Status 368 | 395 | 396 | 397 | 398 | 399 | 400 | OnAfterSave. Exports source controlled files to external file 401 | InternalName:%String,Object:%RegisteredObject 402 | %Status 403 | 424 | 425 | 426 | 427 | 428 | 429 | Exports to external file 430 | InternalName:%String,Filename:%String 431 | %Status 432 | =2016.2) 434 | 435 | #if $$$isUDLSupported 436 | // Caché version supports exporting as UDL 437 | // UDL option enabled and file extension supports UDL, export as UDL 438 | set ext = $zconvert($piece(InternalName,".",$length(InternalName,".")),"l") 439 | if ..UseUDL,..CanExportExtensionUDL(ext) { 440 | quit $system.OBJ.ExportUDL(InternalName, Filename, "-d /diffexport") 441 | } 442 | #else 443 | // Caché does not support exporting as UDL. 444 | // UDL option enabled, log an error and continue to export as XML. 445 | if ..UseUDL { 446 | do ..Logger.Error("Caché version "_$zv_" does not support exporting as UDL. Using XML instead...") 447 | } 448 | #endif 449 | 450 | // Default, export as XML. 451 | quit $system.OBJ.Export(InternalName, Filename, "-d /diffexport") 452 | ]]> 453 | 454 | 455 | 456 | 457 | 458 | OnAfterCompile. Same as OnAfterSave 459 | InternalName:%String 460 | %Status 461 | 463 | 464 | 465 | 466 | 467 | 468 | Called after an item is deleted. 469 | InternalName:%String 470 | %Status 471 | 477 | 478 | 479 | 480 | 481 | 482 | Deletes a source controlled item 483 | InternalName:%String 484 | %Status 485 | 495 | 496 | 497 | 498 | 499 | 500 | Provides a normalized way to format InternalNames (uppercase extension) 501 | 1 502 | InternalName:%String 503 | 508 | 509 | 510 | 511 | 512 | 513 | Returns the external name (external file name) corresponding to a Caché element 514 | InternalName:%String 515 | %String 516 | 537 | 538 | 539 | 540 | 541 | 542 | Returns the internal name corresponding to an external file 543 | ExternalName:%String 544 | %String 545 | 558 | 559 | 560 | 561 | 562 | 563 | Prints out output from git command 564 | 565 | %String 566 | 579 | 580 | 581 | 582 | 583 | 584 | Returns if an item is supported or not 585 | InternalName:%String 586 | 1 587 | %Status 588 | 604 | 605 | 606 | 607 | 608 | 609 | Returns if an extension can 610 | extension:%String="" 611 | %Integer 612 | 614 | 615 | 616 | 617 | list: 620 | Files marked as "D" will be deleted, rest will be reloaded 621 | Each file entry should be like: 622 | A path/file.xml 623 | M path/file1.xml 624 | D path/file2.xml]]> 625 | 626 | 1 627 | >Ignoring "_file) 643 | } 644 | elseif status'="D" { 645 | do ..Logger.Info(">>Loading "_internalname) 646 | set tSC=..OnBeforeLoad(internalname) 647 | set updated = updated_$lb(internalname) 648 | } 649 | elseif status="D" { 650 | do ..Logger.Info(">>Deleting "_internalname) 651 | set tSC=##class(%RoutineMgr).Delete(internalname) 652 | set tSC=..DeleteControlledItem(internalname) 653 | set deleted = deleted_$lb(internalname) 654 | } 655 | } 656 | 657 | // callback 658 | if ..OnReloadFiles'=""{ 659 | do ..Logger.Info($char(13)_">Calling on.reloadfiles callback: "_$listget(..OnReloadFiles,1)_":"_$listget(..OnReloadFiles,2)) 660 | do ..Logger.Info(">result="_$classmethod($listget(..OnReloadFiles,1), $listget(..OnReloadFiles,2), updated, deleted)) 661 | } 662 | ]]> 663 | 664 | 665 | 666 | 670 | 671 | 672 | 673 | 677 | 678 | 679 | 680 | 684 | 685 | 686 | 687 | 688 | 689 | Returns status of an item 690 | 691 | %Status 692 | 710 | 711 | 712 | 713 | 714 | 715 | Commits 716 | InternalName:%String,Description:%String,pAmend:%Boolean=0 717 | %Status 718 | 728 | 729 | 730 | 731 | 732 | 733 | Reverts an item 734 | InternalName:%String 735 | %Status 736 | 743 | 744 | 745 | 746 | 747 | 748 | Check if item is under source control 749 | InternalName:%String 750 | %Boolean 751 | 755 | 756 | 757 | 758 | 759 | 760 | Adds an item 761 | InternalName:%String,Description:%String 762 | %Status 763 | 774 | 775 | 776 | 777 | 778 | 779 | Returns source control log of an item 780 | InternalName:%String 781 | %Status 782 | 787 | 788 | 789 | 790 | 791 | 792 | Returns source control log of an item 793 | InternalName:%String 794 | %Status 795 | 800 | 801 | 802 | 803 | 804 | 805 | Returns source control status of entire working directory 806 | InternalName:%String 807 | %Status 808 | 813 | 814 | 815 | 816 | 817 | 818 | Adds all changes to stage 819 | %Status 820 | 828 | 829 | 830 | 831 | 832 | 833 | Unstages a file 834 | InternalName:%String 835 | %Status 836 | 841 | 842 | 843 | 844 | 845 | 846 | Creates a new branch 847 | pBranch:%String 848 | %Status 849 | 854 | 855 | 856 | 857 | 858 | 859 | List branches 860 | pBranch:%String 861 | %Status 862 | 867 | 868 | 869 | 870 | 871 | 872 | Creates a branch and then switch to it 873 | pBranch:%String 874 | %Status 875 | 882 | 883 | 884 | 885 | 886 | 887 | Switchs workspace to branch 888 | pBranch:%String 889 | %Status 890 | Analyzing files after changing from """_current_""" to """_pBranch_"""") 903 | do ..ReloadFiles(.files, .updated, .deleted) 904 | do ..Logger.Info(">Completed.") 905 | 906 | quit tSC 907 | ]]> 908 | 909 | 910 | 911 | 912 | 913 | Diffs current branch with other branch 914 | pBranch:%String 915 | %Status 916 | 921 | 922 | 923 | 924 | 925 | 926 | Merges with a branch 927 | pBranch:%String 928 | %Status 929 | 934 | 935 | 936 | 937 | 938 | 939 | Aborts a merge 940 | %Status 941 | 946 | 947 | 948 | 949 | 950 | 951 | Lists current git config 952 | %Status 953 | 958 | 959 | 960 | 961 | 962 | 963 | Loads changes (as shown in git status) 964 | %Status 965 | Reloading changed files:") 971 | do ..ReloadFiles(.output, .updated, .deleted) 972 | do ..Logger.Info(">Completed.") 973 | 974 | quit tSC 975 | ]]> 976 | 977 | 978 | 979 | 980 | 981 | Pushes local changes to origin 982 | %Status 983 | 988 | 989 | 990 | 991 | 992 | 993 | Pulls fresh changes from origin to local 994 | pDry:%Boolean=0 995 | %Status 996 | Reloading diff with: origin"_"/"_current) 1013 | do ..ReloadFiles(.out2, .updated, .deleted) 1014 | do ..Logger.Info(">Completed.") 1015 | } 1016 | 1017 | if $$$ISOK(tSC),..OnPull'=""{ 1018 | do ..Logger.Info($char(13)_">Calling on.pull callback: "_$listget(..OnPull,1)_":"_$listget(..OnPull,2)) 1019 | do ..Logger.Info(">result="_$classmethod($listget(..OnPull,1), $listget(..OnPull,2), updated, deleted)) 1020 | } 1021 | 1022 | quit tSC 1023 | ]]> 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | Loads modified files from workdir and checks for troubled ^SourceControl entries 1030 | pPath:%String 1031 | %Status 1032 | Reloading files based on GIT status:") 1038 | do ..ReloadFiles(.output, .updated, .deleted) 1039 | do ..Logger.Info(">Completed.") 1040 | 1041 | // check for deleted 1042 | set file="" 1043 | for { 1044 | set file=$order(^SourceControl(1,file)) 1045 | quit:file="" 1046 | 1047 | set extname=..ExternalName(file) 1048 | if '##class(%File).Exists(extname) { 1049 | do ..Logger.Info(">>Deleting "_file_" because it is in ^SourceControl but not in workdir") 1050 | set tSC=##class(%RoutineMgr).Delete(file) 1051 | set tSC=..DeleteControlledItem(file) 1052 | kill ^SourceControl(1,file) 1053 | } 1054 | } 1055 | 1056 | // callback 1057 | if $$$ISOK(tSC),..OnWorkDirLoad'=""{ 1058 | do ..Logger.Info($char(13)_">Calling on.workdirload callback: "_$listget(..OnWorkDirLoad,1)_":"_$listget(..OnWorkDirLoad,2)) 1059 | do ..Logger.Info(">result="_$classmethod($listget(..OnWorkDirLoad,1), $listget(..OnWorkDirLoad,2), updated, deleted)) 1060 | } 1061 | 1062 | quit tSC 1063 | ]]> 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | Adds classes (only non-generated) which name starts with pStartsWith. 1070 | (useful to add a bunch of classes belonging to a package from Terminal). 1071 | 1 1072 | pStartsWith:%String 1073 | %Status 1074 | 1094 | 1095 |
1096 |
1097 | -------------------------------------------------------------------------------- /cache/cls/Studio/SourceControl/Sample/Callback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Sample callback class 6 | %RegisteredObject 7 | 64320,54474.354168 8 | 9 | 10 | 1 11 | updated:%List,deleted:%List 12 | %Status 13 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /cache/cls/Studio/SourceControl/Util/Logger.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Handles log messages using log levels 7 | %RegisteredObject 8 | 62549,35585.773344 9 | 10 | 11 | 12 | Current log level 13 | 2 14 | 15 | 16 | 17 | 1 18 | 19 | 20 | 21 | 2 22 | 23 | 24 | 25 | 7 26 | 27 | 28 | 29 | 1 30 | pLevel:%String,pMsg:%String,pNL:%Boolean=1 31 | = ..#LOGLEVEL { 33 | write:pNL ! 34 | write pMsg 35 | } 36 | quit 37 | ]]> 38 | 39 | 40 | 41 | 1 42 | pMsg:%String,pNL:%Boolean=1 43 | 45 | 46 | 47 | 48 | 1 49 | pMsg:%String,pNL:%Boolean=1 50 | 52 | 53 | 54 | 55 | 1 56 | pMsg:%String,pNL:%Boolean=1 57 | 59 | 60 | 61 | 62 | --------------------------------------------------------------------------------