Skip to content

Commit 704b944

Browse files
authored
Git add packages (#79)
* committing to see deleted file * staged deleted file * Staging another file to delete later * Staging class file to see how delete works * clean up * Commit to test delete in Uncommitted queue * minor refactoring * delete class file made for testing * Add code to remove file from Uncommitted queue after commit. * Remove unneeded file * Uncommitted queue now saves deleted files * Commit changes with logging statements for testing * Adding packages to source control now works properly * Remove changes carried over from unrelated branch * Made the fix for package names not having the .pkg extension on VS Code more universal Co-authored-by: Sarmishta Velury <[email protected]>
1 parent 4c70052 commit 704b944

File tree

5 files changed

+47
-34
lines changed

5 files changed

+47
-34
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.vscode/
2-
testcode.txt
32
.gitattributes
43
*.code-workspace
54
package-lock.json

cls/SourceControl/Git/Change.cls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,3 @@ ClassMethod RefreshUncommitted(Display = 1, IncludeRevert = 0) As %Status
8888
}
8989

9090
}
91-

cls/SourceControl/Git/Extension.cls

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ Method UserAction(Type As %Integer, Name As %String, InternalName As %String, Se
4747
if menu '= "%SourceMenu", menu'="%SourceContext" {
4848
quit $$$OK
4949
}
50+
do $System.OBJ.GetPackageList(.files,InternalName)
51+
if ($DATA(files) '= 0) {
52+
set InternalName = ($piece($order(files("")), ".", 1)_".pkg")
53+
}
5054
set InternalName = ##class(Utils).NormalizeInternalName(InternalName)
5155
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
5256
set ec = ##class(Utils).UserAction(InternalName, Name, .Target, .Action, .Reload)
@@ -160,6 +164,14 @@ Method OnSourceMenuContextItem(itemName As %String, menuItemName As %String, ByR
160164
/// this menu item from the list totally, 0 will gray the menu item out and the default 1 will display the menu item as normal.
161165
Method OnMenuItem(MenuName As %String, InternalName As %String, SelectedText As %String, ByRef Enabled As %Boolean, ByRef DisplayName As %String) As %Status
162166
{
167+
168+
if (InternalName '= ""){
169+
do $System.OBJ.GetPackageList(.files,InternalName)
170+
if ($DATA(files) '= 0) {
171+
set InternalName = ($piece($order(files("")), ".", 1)_".pkg")
172+
}
173+
}
174+
163175
set InternalName = ##class(Utils).NormalizeInternalName(InternalName)
164176
set context = ##class(SourceControl.Git.PackageManagerContext).ForInternalName(InternalName)
165177

@@ -303,4 +315,3 @@ Method GetStatus(InternalName As %String, ByRef IsInSourceControl As %Boolean, B
303315
}
304316

305317
}
306-

cls/SourceControl/Git/Utils.cls

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -254,33 +254,33 @@ ClassMethod Revert(InternalName As %String) As %Status
254254
quit $$$OK
255255
}
256256

257-
ClassMethod NewBranch(newBranchName As %String) As %Status
257+
ClassMethod Commit(InternalName As %String, Message As %String = "example commit message") As %Status
258258
{
259-
do ..RunGitWithArgs(.errStream, .outStream, "checkout", "-b", newBranchName)
260-
do errStream.OutputToDevice()
259+
set filename = ..FullExternalName(InternalName)
260+
set username = ..GitUserName()
261+
set email = ..GitUserEmail()
262+
set author = username_" <"_email_">"
263+
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Message, filename)
264+
write !
261265
do outStream.OutputToDevice()
266+
write !
267+
do errStream.OutputToDevice()
262268
quit $$$OK
263269
}
264270

265-
ClassMethod SwitchBranch(targetBranchName As %String) As %Status
271+
ClassMethod NewBranch(newBranchName As %String) As %Status
266272
{
267-
do ..RunGitWithArgs(.errStream, .outStream, "checkout", targetBranchName)
273+
do ..RunGitWithArgs(.errStream, .outStream, "checkout", "-b", newBranchName)
268274
do errStream.OutputToDevice()
269275
do outStream.OutputToDevice()
270276
quit $$$OK
271277
}
272278

273-
ClassMethod Commit(InternalName As %String, Message As %String = "example commit message") As %Status
279+
ClassMethod SwitchBranch(targetBranchName As %String) As %Status
274280
{
275-
set filename = ..FullExternalName(InternalName)
276-
set username = ..GitUserName()
277-
set email = ..GitUserEmail()
278-
set author = username_" <"_email_">"
279-
do ..RunGitWithArgs(.errStream, .outStream, "commit", "--author", author, "-m", Message, filename)
280-
write !
281-
do outStream.OutputToDevice()
282-
write !
281+
do ..RunGitWithArgs(.errStream, .outStream, "checkout", targetBranchName)
283282
do errStream.OutputToDevice()
283+
do outStream.OutputToDevice()
284284
quit $$$OK
285285
}
286286

@@ -386,14 +386,17 @@ ClassMethod AddToSourceControl(InternalName As %String) As %Status
386386
for i = 1:1:$length(InternalName, ",") {
387387
#dim item as %String = ..NormalizeExtension($piece(InternalName, ",", i))
388388
set @..#Storage@("items", item) = ""
389-
#dim sc as %Status = ..ExportItem(item)
389+
#dim sc as %Status = ..ExportItem(item,,,.filenames)
390390
if 'sc {
391391
set ec = $$$ADDSC(ec, sc)
392392
}
393-
// Necessary for items in new folders
394-
do ..RunGitCommand("add",.errStream,.outStream,..ExternalName(InternalName))
395-
do outStream.OutputToDevice()
396-
do errStream.OutputToDevice()
393+
#dim extension = $piece(item, ".", $length(item, "."))
394+
395+
for i=1:1:filenames{
396+
do ..RunGitCommand("add",.errStream,.outStream,filenames(i))
397+
do outStream.OutputToDevice()
398+
do errStream.OutputToDevice()
399+
}
397400
}
398401
set ec = $$$ADDSC(ec, ..ExportSCList())
399402
quit ec
@@ -448,7 +451,7 @@ ClassMethod RemoveFromSourceControl(InternalName As %String) As %Status
448451
} else {
449452
#dim parentElement as %String = ""
450453
if ..IsInSourceControl(item, .parentElement) {
451-
set tsc = ..MakeError(item _ " is contained in "_parentElement_" that tracked by SourceControl")
454+
set tsc = ..MakeError(item _ " is contained in "_parentElement_" that tracked is by SourceControl")
452455
}else {
453456
set tsc = ..MakeError(item _ " is not in SourceControl")
454457
}
@@ -918,7 +921,7 @@ ClassMethod ImportRoutines(force As %Boolean = 0) As %Status
918921
quit ec
919922
}
920923

921-
ClassMethod ExportRoutinesAux(path As %String, sep As %String = "", level As %Integer = 0, force As %Boolean = 0) As %Status
924+
ClassMethod ExportRoutinesAux(path As %String, sep As %String = "", level As %Integer = 0, force As %Boolean = 0, ByRef filenames) As %Status
922925
{
923926
#define Dir
924927
#define OrderBy
@@ -941,32 +944,33 @@ ClassMethod ExportRoutinesAux(path As %String, sep As %String = "", level As %In
941944

942945
if (type = $$$Directory) || (type = $$$CSPFolder) {
943946
#dim newpath as %String = $case(path,"":name,:path_isdirectory_name)
944-
do ..ExportRoutinesAux(newpath, isdirectory, level + 1, force)
947+
do ..ExportRoutinesAux(newpath, isdirectory, level + 1, force, .filenames)
945948
} else {
946949
#dim InternalName as %String = path_sep_name
947950
if (type = $$$CspFile) && ($extract(InternalName) '= "/") {
948951
set InternalName = "/"_InternalName
949952
}
950-
set ec = ..ExportItem(InternalName, 1, force)
953+
set ec = ..ExportItem(InternalName, 1, force, .filenames)
951954
}
952955
}
953956
kill rs
954957
quit ec
955958
}
956959

957-
ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As %Boolean = 0) As %Status
960+
ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As %Boolean = 0, ByRef filenames) As %Status
958961
{
959962
#dim type = ..Type(InternalName)
960963
if type = "pkg" {
961-
$$$QuitOnError(..ExportRoutinesAux(..NameWithoutExtension(InternalName), ".", 0, force))
964+
$$$QuitOnError(..ExportRoutinesAux(..NameWithoutExtension(InternalName), ".", 0, force, .filenames))
962965
}elseif type = "prj" && expand {
963-
$$$QuitOnError(..ExportProject(..NameWithoutExtension(InternalName), force))
964-
$$$QuitOnError(..ExportItem(InternalName, 0, force))
966+
$$$QuitOnError(..ExportProject(..NameWithoutExtension(InternalName), force, .filenames))
967+
$$$QuitOnError(..ExportItem(InternalName, 0, force, .filenames))
965968
}elseif (type = "csp") && ..IsCspFolder(InternalName) {
966-
$$$QuitOnError(..ExportRoutinesAux(InternalName , "/", 0, force))
969+
$$$QuitOnError(..ExportRoutinesAux(InternalName , "/", 0, force, .filenames))
967970
}else {
968971
if ..IsTempFileOutdated(InternalName) || force {
969972
#dim filename as %String = ..FullExternalName(InternalName)
973+
set filenames($I(filenames)) = filename
970974
write "exporting new version of ", InternalName, " to ", filename,!
971975
$$$QuitOnError($system.OBJ.ExportUDL(InternalName, filename,"-d/diff"))
972976
$$$QuitOnError(..UpdateRoutineTSH(InternalName, $h))
@@ -978,7 +982,7 @@ ClassMethod ExportItem(InternalName As %String, expand As %Boolean = 1, force As
978982
quit $$$OK
979983
}
980984

981-
ClassMethod ExportProject(project As %String, force As %Boolean = 0) As %Status
985+
ClassMethod ExportProject(project As %String, force As %Boolean = 0, ByRef filenames) As %Status
982986
{
983987
#dim rs as %ResultSet = ##class(%ResultSet).%New("%Studio.Project:ProjectItemsList")
984988
$$$QuitOnError(rs.Execute(project))
@@ -988,7 +992,7 @@ ClassMethod ExportProject(project As %String, force As %Boolean = 0) As %Status
988992
if $listfind(typesWithoutExtension, rs.Get("Type")) {
989993
set name = name _ "." _ rs.Get("Type")
990994
}
991-
#dim ec as %Status = ..ExportItem(name, 1, force)
995+
#dim ec as %Status = ..ExportItem(name, 1, force, .filenames)
992996
quit:'ec
993997
}
994998
kill rs

git-webui/release/share/git-webui/webui/js/git-webui.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,4 +2049,4 @@ $(function () {
20492049
e.preventDefault();
20502050
location.reload()
20512051
});
2052-
});
2052+
});

0 commit comments

Comments
 (0)