Przeglądaj źródła

2023-04-28.10:22:56

tianyun 2 lat temu
rodzic
commit
d01cf6c869
1 zmienionych plików z 2 dodań i 5 usunięć
  1. 2 5
      sh/git_cp_file.sh

+ 2 - 5
sh/git_cp_file.sh

@@ -1,18 +1,14 @@
-#!/bin/bash
-
 # 从命令行参数获取分支名和正则表达式
 dev_branch=$(git branch --show-current)
 test_branch=$1
 grep_pattern=$2
-show_diff=$3
 
 # 使用git diff命令查找test分支相对于dev分支修改的文件名,然后使用grep过滤文件名
-files=$(git diff --name-only ${dev_branch}..${test_branch} | egrep ${grep_pattern})
+files=$(git diff --name-only ${dev_branch}..${test_branch} | egrep "${grep_pattern}")
 
 echo "找到文件:"${files}
 
 read -p "请输入 y 继续执行脚本:" input
-
 if [ ! "${input}" = "y" ]; then
     echo "退出脚本"
     exit 1
@@ -24,6 +20,7 @@ for file in $files; do
   if [ ! -f ${file} ]; then
       mkdir -p "$(dirname "${file}")"
       touch ${file}
+      git add ${file}
   fi
   echo "git checkout ${test_branch} ${file}"
   git checkout ${test_branch} ${file}