Skip to content

Removing from source control now works #80

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 3 commits into from
Nov 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion cls/SourceControl/Git/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,13 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
quit ec
}

ClassMethod RemoveFromGit(InternalName)
{
#dim fullName = ##class(Utils).FullExternalName(InternalName)
do ..RunGitCommand("rm",.errStream,.outStream,"--cached", fullName)
do errStream.OutputToDevice()
}

ClassMethod DeleteExternalsForItem(InternalName As %String) As %Status
{
#dim type as %String = ..Type(InternalName)
Expand All @@ -425,16 +432,19 @@ ClassMethod DeleteExternalsForItem(InternalName As %String) As %Status
if 'sc {
set ec = $$$ADDSC(ec, sc)
}
do ..RemoveFromGit(item)
}
}
} else {
set ec = ..DeleteExternalFile(InternalName)
do ..RemoveFromGit(InternalName)
}
quit ec
}

ClassMethod RemoveFromSourceControl(InternalName As %String) As %Status
{
write !
#dim sc as %Status = $$$OK
for i = 1:1:$length(InternalName, ",") {
#dim tsc as %Status = $$$OK
Expand Down Expand Up @@ -828,8 +838,28 @@ ClassMethod ImportItem(InternalName As %String, force As %Boolean = 0, verbose A
ClassMethod ListItemsInFiles(ByRef itemList, ByRef err) As %Status
{
#define DoNotLoad 1
set res = $system.OBJ.ImportDir(..TempFolder(),"*.xml","-d",.err,1, .itemList, $$$DoNotLoad)

set mappingFileType = $order($$$SourceMapping(""))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thought: we don't require explicit mappings if you're loading via the package manager. Might be worth considering the behavior of ListItemsInFiles in this case as well. (Though it's much trickier... Happy to just not worry about it for now.)

while (mappingFileType '= "") {

set mappingCoverage = $order($$$SourceMapping(mappingFileType, ""))

while (mappingCoverage '= ""){

set mappedRelativePath = $$$SourceMapping(mappingFileType, mappingCoverage)
set mappedFilePath = ##class(%File).NormalizeFilename(mappedRelativePath, ..TempFolder())

if (##class(%File).DirectoryExists(mappedFilePath)){
set res = $system.OBJ.ImportDir(mappedFilePath,,"-d",.err,1, .tempItemList, $$$DoNotLoad)
merge itemList = tempItemList
}

set mappingCoverage = $order($$$SourceMapping(mappingFileType, mappingCoverage))
}

set mappingFileType = $order($$$SourceMapping(mappingFileType))
}

if '$data(itemList) && $$$ISERR(res) {
quit res
}
Expand Down