-
Notifications
You must be signed in to change notification settings - Fork 8
Safeguard discard #459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Safeguard discard #459
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1f74651
mostly done with changes
isc-hwojnick b0ff143
feat: discard safeguard finished
isc-hwojnick 97a5233
docs: update changelog
isc-hwojnick fb94fd1
Fix discarding external files (not in IRIS)
isc-etamarch aa05260
Merge branch 'main' into safeguard-discard
isc-etamarch 902972e
Replace removed discarded-state code
isc-etamarch b9e1c13
Fix bug in webdriver handling
isc-etamarch 8cd6ee7
Fix SQL issues, fix file restoration
isc-etamarch 9eb7ad8
fix macro call
isc-etamarch 8c49654
Fix file restore
isc-etamarch 6f4c805
Safeguard-discard on menu-based discard
isc-etamarch 8739093
Fix UI and post-discard refresh
isc-etamarch 10aa944
Fix restore files after discard
isc-etamarch 31862a8
Remove from uncommitted queue after discard
isc-etamarch 89dd12b
Fix discarded items still in uncommitted queue
isc-etamarch ec6e5a5
typo
isc-etamarch 078d56e
Bump version
isc-etamarch 4956dd3
Merge branch 'main' into safeguard-discard
isc-etamarch bf99a2d
Fix issues
isc-etamarch a3368b2
Merge branch 'main' into safeguard-discard
isc-etamarch 5fe6a7c
Merge branch 'main' into safeguard-discard
isc-etamarch b8b143c
Compile discarded classes and fix file contents
isc-etamarch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 ]; | ||
isc-etamarch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 = ?" | ||
isc-etamarch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.