-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into fix-450
- Loading branch information
Showing
20 changed files
with
678 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
Class SourceControl.Git.DiscardState Extends (%Persistent, %JSON.Adaptor) | ||
{ | ||
|
||
Property FullExternalName As %String(MAXLEN = "") [ Required ]; | ||
|
||
Property Name As %String [ Required ]; | ||
|
||
Property Contents As %Stream.GlobalCharacter(LOCATION = "^SourceControl.Git.DiscardS"); | ||
|
||
Property Username As %String [ Required ]; | ||
|
||
Property Branch As %String [ Required ]; | ||
|
||
Property Timestamp As %TimeStamp [ Required ]; | ||
|
||
Property ExternalFile As %Boolean [ Required ]; | ||
|
||
Index BranchMap On Branch [ Type = bitmap ]; | ||
|
||
Method RestoreToFileTree() | ||
{ | ||
// Make sure directory for file exists | ||
set dir = ##class(%File).GetDirectory(..FullExternalName) | ||
if ('##class(%File).DirectoryExists(dir)) { | ||
do ##class(%File).CreateDirectoryChain(dir) | ||
} | ||
|
||
// Recreate File | ||
set fileStream = ##class(%Stream.FileCharacter).%New() | ||
set fileStream.Filename = ..FullExternalName | ||
$$$ThrowOnError(fileStream.CopyFrom(..Contents)) | ||
$$$ThrowOnError(fileStream.%Save()) | ||
|
||
// Add file to source-control / IRIS | ||
if '..ExternalFile { | ||
do ##class(SourceControl.Git.Utils).ImportItem(..Name, 1, 1, 1) | ||
do ##class(SourceControl.Git.Utils).AddToServerSideSourceControl(..Name) | ||
} | ||
|
||
// Delete discard record | ||
$$$ThrowOnError(..%DeleteId(..%Id())) | ||
} | ||
|
||
ClassMethod SaveDiscardState(InternalName As %String, name As %String) As %Status | ||
{ | ||
set discardState = ..%New() | ||
|
||
if (InternalName = "") { | ||
// If not in IRIS | ||
set externalName = ##class(%File).Construct(##class(SourceControl.Git.Utils).DefaultTempFolder(),name) | ||
set discardState.FullExternalName = externalName | ||
set discardState.Name = name | ||
set discardState.ExternalFile = 1 | ||
} else { | ||
set discardState.FullExternalName = ##class(SourceControl.Git.Utils).FullExternalName(InternalName) | ||
set discardState.Name = InternalName | ||
set discardState.ExternalFile = 0 | ||
} | ||
// Copy over file contents | ||
set fileStream = ##class(%Stream.FileCharacter).%New() | ||
set fileStream.Filename = discardState.FullExternalName | ||
do fileStream.%Open() | ||
do discardState.Contents.CopyFrom(fileStream) | ||
do fileStream.%Close() | ||
|
||
// Save extra information | ||
set discardState.Username = $USERNAME | ||
set discardState.Branch = ##class(SourceControl.Git.Utils).GetCurrentBranch() | ||
set discardState.Timestamp = $zdatetime($horolog, 3) | ||
|
||
set st = discardState.%Save() | ||
|
||
quit st | ||
} | ||
|
||
ClassMethod DiscardStatesInBranch() As %DynamicArray | ||
{ | ||
set currentBranch = ##class(SourceControl.Git.Utils).GetCurrentBranch() | ||
|
||
set query = "SELECT ID FROM SourceControl_Git.DiscardState WHERE branch = ?" | ||
set statement = ##class(%SQL.Statement).%New() | ||
set status = statement.%Prepare(query, 0) | ||
$$$ThrowOnError(status) | ||
set resultSet = statement.%Execute(currentBranch) | ||
if (resultSet.%SQLCODE < 0) { | ||
throw ##class(%Exception.SQL).CreateFromSQLCODE(resultSet.%SQLCODE,resultSet.%Message) | ||
} | ||
|
||
set discardStates = [] | ||
while resultSet.%Next() { | ||
set discardState = ..%OpenId(resultSet.ID) | ||
do discardState.%JSONExportToString(.JSONStr) | ||
set discardStateObject = ##class(%DynamicAbstractObject).%FromJSON(JSONStr) | ||
set discardStateObject.Id = resultSet.ID | ||
do discardStates.%Push(discardStateObject) | ||
} | ||
|
||
quit discardStates | ||
} | ||
|
||
Storage Default | ||
{ | ||
<Data name="DiscardStateDefaultData"> | ||
<Value name="1"> | ||
<Value>%%CLASSNAME</Value> | ||
</Value> | ||
<Value name="2"> | ||
<Value>FullExternalName</Value> | ||
</Value> | ||
<Value name="3"> | ||
<Value>InternalName</Value> | ||
</Value> | ||
<Value name="4"> | ||
<Value>Contents</Value> | ||
</Value> | ||
<Value name="5"> | ||
<Value>Username</Value> | ||
</Value> | ||
<Value name="6"> | ||
<Value>Branch</Value> | ||
</Value> | ||
<Value name="7"> | ||
<Value>Timestamp</Value> | ||
</Value> | ||
<Value name="8"> | ||
<Value>Name</Value> | ||
</Value> | ||
<Value name="9"> | ||
<Value>ExternalFile</Value> | ||
</Value> | ||
</Data> | ||
<DataLocation>^SourceControl22B9.DiscardStateD</DataLocation> | ||
<DefaultData>DiscardStateDefaultData</DefaultData> | ||
<IdLocation>^SourceControl22B9.DiscardStateD</IdLocation> | ||
<IndexLocation>^SourceControl22B9.DiscardStateI</IndexLocation> | ||
<StreamLocation>^SourceControl22B9.DiscardStateS</StreamLocation> | ||
<Type>%Storage.Persistent</Type> | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,5 +68,4 @@ Storage Default | |
<Type>%Storage.Persistent</Type> | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,5 +50,4 @@ Method Dump() | |
write !?4,"Git-enabled? ",$select(..IsInGitEnabledPackage:"Yes",1:"No"),! | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,5 +44,4 @@ ClassMethod ForInternalNames(InternalName As %String) As %Status | |
quit ..ForModifications(.files) | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,4 @@ Method OnPull() As %Status | |
quit ##class(SourceControl.Git.PullEventHandler.IncrementalLoad)$this.OnPull() | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,4 @@ Method OnPull() As %Status | |
quit ##class(%ZPM.PackageManager).Shell("load "_..LocalRoot) | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,5 +280,4 @@ Method UsePreviousDeviceAndSettings() [ Internal, Private ] | |
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,5 +153,4 @@ ClassMethod ResolveStream(stream As %Stream.Object) | |
Quit 1 | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,5 +166,4 @@ Method %RemoveOref() As %Status [ CodeMode = objectgenerator, Final, Internal, P | |
Quit $$$OK | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.