0

I am using Quality Center to execute tests in Windows 8. The VBScript file creates a temporary (timestamped) workspace/folder to clone the git repository and execute the test.

When I try to remove the folder in the end of the test, it doesn't work and gives an error: Invalid field type definition.

This code works fine if I work with a non git repository and a static project. If I delete manually the .git folder, the script is able to remove the remaining of the folders/files.

'''workspace = "C:\tests\20170613224942"
Dim objFSO, objFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CreateFolder(workspace)

'git clone
'Test Execution

Dim objFSO, objFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")

objFSO.DeleteFolder(workspace)

I already tried (unsuccessfully) something like that:

objShell.Run "rmdir /S /Q " & workspace

I don't know if its problem with hidden folder so I tried this:

del /s /a *.git

But this only works for files and in this case only the folder is hidden. Not the sub-folders/sub-files.

Can someone help me to resolve this problem? How can I force the folder removal automatically via script? Thank you.

koxta
  • 846
  • 2
  • 8
  • 30

2 Answers2

0

Can you try :

git rm -r gitDirectoryToRemove

and then your code to remove the parent if required

smilyface
  • 5,021
  • 8
  • 41
  • 57
  • I tried and give me the error: fatal: Not a git repository (or any of the parent directories): .git – koxta Jun 14 '17 at 11:00
  • Got it. Then you are trying to access the GIT / trying to command from an non-git directory. You should change directory to the git parent folder before entering the git command – smilyface Jun 14 '17 at 11:08
  • Inside git parent folder, the command works but only the project/code is removed. The folder **.git** (problematic folder) its not deleted. – koxta Jun 14 '17 at 11:47
  • Which is the directory you actually trying to remove (say D:\workspace\temp\GitProject ) - here workspace OR temp OR GitProject ? – smilyface Jun 14 '17 at 12:47
  • Try this - Go to git directory and then `rd /s /q` OR `del /s /q .git` `rmdir /s /q .git` . Any of these should work for you. – smilyface Jun 14 '17 at 12:53
  • Unfortunately only works if I execute them directly in command line. In VBScript do nothing. But thanks for the suggestion. – koxta Jun 14 '17 at 13:51
0

Found a temporary solution. Maybe not an elegant one, but solves the problem. I created a .bat file only for removing the folder passed by argument and I call it in VBS.

Bat File:

@echo off
@echo Try to removing %1
rmdir "%1" /s/q

VBS Call:

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "C:\tests\rm_workspace.bat " & workspace

Removing indirectly, it works like a charm. The reason: still don't know why.

koxta
  • 846
  • 2
  • 8
  • 30