CI校驗(yàn)不通過(guò),竟然被自己坑死了
大家好,我是TianTian。
分享的內(nèi)容是工作中一些瑣碎的事情。
記錄一下我是如何被git config坑的,導(dǎo)致CI校驗(yàn)竟然不通過(guò)。
事故由來(lái)
當(dāng)我把bug解決休掉后,順利跑通后。”愉快“的補(bǔ)完單測(cè),提了個(gè)mr,CI校驗(yàn)竟然攔下來(lái)了。
圖1
當(dāng)時(shí)我的心情是復(fù)雜的,于是我點(diǎn)開(kāi)了這個(gè)Details。
看了半天,沒(méi)有啥有價(jià)值的錯(cuò)誤信息,接著索性打開(kāi)這個(gè)流水線,看看藍(lán)盾里面具體是哪個(gè)子流失線出現(xiàn)了問(wèn)題,找了半天后,發(fā)現(xiàn)了問(wèn)題。。。
圖2
好離譜,為啥我git email盡然有QQ郵箱。。。
為了驗(yàn)證我這個(gè)分支是否存在上述的這個(gè)問(wèn)題,我得排查一下:
- git log | grep 'Author' | head
看到結(jié)果的時(shí)候,我呆滯住了:
圖3
居然真的有個(gè)commit記錄真的是qq郵箱,事情大概清楚了,之前master分支存在問(wèn)題,我刪掉項(xiàng)目,重新拉取一次master分支。
由于我全局配置的git config 是日常郵箱的問(wèn)題,沒(méi)有在意這個(gè)問(wèn)題,導(dǎo)致現(xiàn)在CI校驗(yàn)不通過(guò)。
那么解決問(wèn)題的辦法就是:
修改下commit歷史
如何解決
于是google一個(gè)方案,修改 git 歷史提交 commit 信息(重寫(xiě)歷史),文檔鏈接:
https://www.jianshu.com/p/0f1fbd50b4be
大致意思通過(guò) git rebase 命令,來(lái)完成操作:
- git rebase -i HEAD~3
- // 修改近三次的信息
將會(huì)得到如下的信息,這里的提交日志是和git log倒敘排列的,我們要修改的日志信息位于第一位:
- 1 pick 2275781 should find method from parent
- 2 pick 223fc80 unit test case
- 3 pick 9ac1179 update test case
- 4
- 5 # Rebase 79db0bd..9ac1179 onto 79db0bd (3 commands)
- 6 #
- 7 # Commands:
- 8 # p, pick = use commit
- 9 # r, reword = use commit, but edit the commit message
- 10 # e, edit = use commit, but stop for amending
- 11 # s, squash = use commit, but meld into previous commit
- 12 # f, fixup = like "squash", but discard this commit's log message
- 13 # x, exec = run command (the rest of the line) using shell
- 14 # d, drop = remove commit
- 15 #
- 16 # These lines can be re-ordered; they are executed from top to bottom.
- 17 #
- 18 # If you remove a line here THAT COMMIT WILL BE LOST.
- 19 #
- 20 # However, if you remove everything, the rebase will be aborted.
- 21 #
- 22 # Note that empty commits are commented out
我們可以根據(jù)Commands信息來(lái)修改這些信息,來(lái)選擇我們需要的參數(shù),最后來(lái)達(dá)到我們的目的。
其他思路
想到我修改的代碼,跟主干代碼master相差的其實(shí)很小,那么我可以做到代碼回滾,根據(jù)我們的id回退到指定的版本,主要通過(guò)的命令就是 git reset,然后選擇對(duì)于的參數(shù),也能滿足我們的需求。
reset的話,通常有三種命令,找了一個(gè)不錯(cuò)的文章,分享一下:
https://www.jianshu.com/p/c2ec5f06cf1a
一般來(lái)說(shuō),有hard,soft,mixed,三種模式,根據(jù)不同的場(chǎng)景來(lái)做選擇。
最后
不說(shuō)了,我準(zhǔn)備寫(xiě)bug去了。