OBKoro1/autoCommit

win10提交失败,运行路径不正确

liunnn1994 opened this issue · 9 comments

系统信息

Operating System: Windows 10 专业版 64-bit (10.0, Build 18363) (18362.19h1_release.190318-1202)
Language: Chinese (Simplified) (Regional Setting: Chinese (Simplified))
Processor: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 CPUs), ~3.2GHz
Memory: 16384MB RAM

vscode版本

版本: 1.41.1 (user setup)
提交: 26076a4de974ead31f97692a0d32f90d735645c0
日期: 2019-12-18T14:58:56.166Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18363

Shell信息

QQ截图20200113095402
cmd,power shell,WSL(Ubuntu)都试过了。

插件运行日志(必填):

git push失败很可能是你的网络有问题,请换到一个网络状况比较良好的地方,然后再项目下执行 git push操作。
错误信息:Error: Command failed: cd e:\test && git pull && git push
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git pull && git push
提交中...
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 09:46'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 09:46'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 15:42'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 15:42'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 21:45'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 21:45'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 12:32'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 12:32'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 07:22'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-13 07:22'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 18:14'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 18:14'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 17:23'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 17:23'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 19:40'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 19:40'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 20:51'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 20:51'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 22:45'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 22:45'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 09:19'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 09:19'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 19:31'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 19:31'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 21:25'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 21:25'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 22:40'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 22:40'
错误信息:Error: Command failed: cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 15:32'
fatal: not a git repository (or any of the parent directories): .git
 fatal: not a git repository (or any of the parent directories): .git

执行命令出错:cd e:\test && git add . && git commit -m 'autoCommit' --date='2020-01-12 15:32'
将要commit的日期: [{"value":"2020-01-12","commitNumber":0},{"value":"2020-01-13","commitNumber":0}]

程序运行参数(必填):

{
    "randomCommit": true,
    "itemSrc": "e:\\test",
    "fileName": "commit.md",
    "commitMsg": "autoCommit",
    "timeArr": [
        {
            "value": [
                "2020-01-12",
                "2020-01-13"
            ],
            "commitNumber": 0
        }
    ],
    "commitNumber": 10
}

怀疑可能是哪里出现问题

不知道源码是什么原理实现的,猜测是shell命令运行路径的问题。可以试试不用cd使用cwd指定路径试试

exec(
  "git status",
  {
    cwd: "e:/test/"
  },
  (err, stdout, stderr) => {}
);

@asdjgfr 因为项目(e:\test)没有.git文件夹,所以会导致执行git命令失败。
你先自己commit一下,看能不能commit成功。

win 下的命令是有问题,需切换到盘符下,再执行命令,下列命令望楼主采纳
let win_index = this.paramsObj.itemSrc.indexOf(":"); let itemSrc =cd ${this.paramsObj.itemSrc}; if (win_index != -1) { // win itemSrc = this.paramsObj.itemSrc.substring(0,win_index + 1); itemSrc += && cd ${this.paramsObj.itemSrc}; } let cmd = itemSrc + && git add . && git commit -m '${this.paramsObj.commitMsg}' --date='${time}';

@asdjgfr 因为项目(e:\test)没有.git文件夹,所以会导致执行git命令失败。
你先自己commit一下,看能不能commit成功。

@OBKoro1 win下面的操作和linux上的不一样,可以pwd看一下路径,ubuntu 18.04 LTS就没有问题

@OBKoro1 可能是因为命令使用了反斜杠"\",而不是斜杠"/"
image

最新版本已修复该问题,如果觉得本插件还不错的话给个Star吧~

命令复制出来在git bash里可以运行,但是在vscode里插件里就会失败,请问是什么原因呢

git push失败很可能是你的网络有问题,请换到一个网络状况比较良好的地方,然后再项目下执行 git push操作。
错误信息:Error: Command failed: cd f:/autocommit && git pull && git push
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

执行命令出错:cd f:/autocommit && git pull && git push
提交中...
错误信息:Error: Command failed: cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-03T09:11:00+08:00'
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

执行命令出错:cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-03T09:11:00+08:00'
错误信息:Error: Command failed: cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-03T16:30:00+08:00'
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

执行命令出错:cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-03T16:30:00+08:00'
错误信息:Error: Command failed: cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-03T21:31:00+08:00'
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

执行命令出错:cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-03T21:31:00+08:00'
错误信息:Error: Command failed: cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-02T18:57:00+08:00'
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

执行命令出错:cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-02T18:57:00+08:00'
错误信息:Error: Command failed: cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-02T22:43:00+08:00'
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

执行命令出错:cd f:/autocommit && git add . && git commit -m 'autoCommit' --date='2020-02-02T22:43:00+08:00'
将要commit的日期: [{"value":"2020-02-02","commitNumber":0},{"value":"2020-02-03","commitNumber":0}]

下了最新的了,还是报了跟上面朋友一样的错误

@zhangyu9609 @chendongchun @asdjgfr 从一个磁盘进入另一个磁盘的问题已修复。

@zhangyu9609 @chendongchun @asdjgfr 从一个磁盘进入另一个磁盘的问题已修复。

已更新,错误已修复,感谢。