Team Foundation Server - Moving Source with History

前端 未结 4 1457
梦毁少年i
梦毁少年i 2020-12-24 10:19

I was wondering what the best approach might be in moving source code, with history, from one Team Project to another Team Project. I am not concerned with work items, repo

4条回答
  •  离开以前
    2020-12-24 11:10

    Regarding the original command above:-

    Get-TfsChildItem $/ProjectA |
    select -Skip 1 |  # skip the root dir
    foreach {
        tf rename $_.serveritem $_.serveritem.replace("$/ProjectA", "$/ProjectB")
    }
    

    Both the source and target names need to be surrounded by quotes in case there are any spaces in the full pathfilename. I found it difficult to do this on $_.ServerItem as surrounding it with escaped " returns that whole child object and not just the .serverItem string. Or if I did manage to get the string, I got unwanted carriage returns such as

    "
    $proj/folder/file
    "

    Eventually I got the command to work with the following, but I found that the history still doesn't get transferred, which was the whole point! So I believe this command is the direct equivalent of just using a right mouse click in source explorer and selecting rename (or move).

    $tfsServerString = "http://machine:8080/tfs/DefaultCollection"
    $tfs = Get-TfsServer $tfsServerString
    Get-TfsChildItem -server $tfs "$/Dest Project/MyTestProject" | select -Skip 1 | foreach { $sourceName = $_.serveritem; $targetName = $_.serveritem.replace("$/Dest Project/MyTestProject/", "$/Dest Project/Source/StoreControllers/dSprint/dSprint2/") ; ./tf rename `"$sourceName`" `"$targetName`" /login:myUser }
    

    Also note, it requires use of the backtick ` to escape "

提交回复
热议问题