让SourceTree也能Export文件

从SVN转到SourceTree,在想导出几个提交版本所牵涉到的文件时, 一定会怀念SVN的Export功能。 怎么让SourceTree也有这个功能呢?

看看在TortoiseSVN里面怎么做的:

  1. Show Log
  2. 选择想导出的那些个Revision
  3. 选择想导出的那些个文件
  4. 在文件上右键, Export...


到了SourceTree里面, 我可怎么也找不到Export的命令。
好在最新版本的SourceTree支持Custom Action。 这样我们就能自己编写Export命令了。

以下是windows的bat命令, 储存为export.bat。 linux下的请按图索骥

@set export_php="E:\projects\sia\tools\export.php"
@set export_dir="E:\projects\sia\export"
@set source_files=%*
@rmdir %export_dir% /s/q
@mkdir %export_dir%
@php %export_php% %source_files%
@explorer %export_dir%

以下是E:\projects\sia\tools\export.php

    <?php
    date_default_timezone_set('Asia/Shanghai');
    if($argc == 0)
    {
        exit('Nothing to copy');
    }
    
    define('DS', DIRECTORY_SEPARATOR); // I always use this short form in my code.
    $source_dir = 'E:'.DS.'projects'.DS.'sia'.DS.'sia';
    $exp_dir = 'E:'.DS.'projects'.DS.'sia'.DS.'export';
    function ExportOneFile($path)
    {
        global $source_dir,$exp_dir;
    
        $final_source = $source_dir.DS.$path;
        $final_dest = $exp_dir.DS.$path;
    
        $final_dest_dir = dirname($final_dest).DS;
        if(!is_dir($final_dest_dir))
        {
            mkdir($final_dest_dir,0777,true);
        }
        return copy($final_source,$final_dest);
    }
    
    foreach($argv as $index=>$path)
    {
        if($index === 0)
        {
            continue;
        }
        if(ExportOneFile($path))
        {
            echo $index.' : '.$path." exported\n";
        }
    }
    
    echo "All Complete. Please go to $exp_dir to view files";


请修改这几个变量指向的路径:

export_php // export.php所在的位置
export_dir // 输出目录所在的位置
$source_dir // 项目文件所在的位置 -- SourceTree所掌控的目录
$exp_dir    // 输出目录所在的位置


最后, 在SourceTree,选择 Tools=>Options=>Custom Actions=>Add

150955_2eYK_726323.png

Script to run 就是那个bat的位置。

ok即可。


以后只需要选择相关的commit, 选择相关的文件。 然后选择Actions=》Custom Actions=》Export... 即可。


导出完毕后, 会自动打开export文件夹。 挺方便的。

转载于:https://my.oschina.net/zgldh/blog/185259

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值