CI校驗(yàn)不通過,竟然被自己坑死了
大家好,我是TianTian。
分享的內(nèi)容是工作中一些瑣碎的事情。
記錄一下我是如何被git config坑的,導(dǎo)致CI校驗(yàn)竟然不通過。
事故由來
當(dāng)我把bug解決休掉后,順利跑通后。”愉快“的補(bǔ)完單測,提了個mr,CI校驗(yàn)竟然攔下來了。
圖1
當(dāng)時我的心情是復(fù)雜的,于是我點(diǎn)開了這個Details。
看了半天,沒有啥有價值的錯誤信息,接著索性打開這個流水線,看看藍(lán)盾里面具體是哪個子流失線出現(xiàn)了問題,找了半天后,發(fā)現(xiàn)了問題。。。
圖2
好離譜,為啥我git email盡然有QQ郵箱。。。
為了驗(yàn)證我這個分支是否存在上述的這個問題,我得排查一下:
- git log | grep 'Author' | head
看到結(jié)果的時候,我呆滯住了:
圖3
居然真的有個commit記錄真的是qq郵箱,事情大概清楚了,之前master分支存在問題,我刪掉項(xiàng)目,重新拉取一次master分支。
由于我全局配置的git config 是日常郵箱的問題,沒有在意這個問題,導(dǎo)致現(xiàn)在CI校驗(yàn)不通過。
那么解決問題的辦法就是:
修改下commit歷史
如何解決
于是google一個方案,修改 git 歷史提交 commit 信息(重寫歷史),文檔鏈接:
https://www.jianshu.com/p/0f1fbd50b4be
大致意思通過 git rebase 命令,來完成操作:
- git rebase -i HEAD~3
- // 修改近三次的信息
將會得到如下的信息,這里的提交日志是和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信息來修改這些信息,來選擇我們需要的參數(shù),最后來達(dá)到我們的目的。
其他思路
想到我修改的代碼,跟主干代碼master相差的其實(shí)很小,那么我可以做到代碼回滾,根據(jù)我們的id回退到指定的版本,主要通過的命令就是 git reset,然后選擇對于的參數(shù),也能滿足我們的需求。
reset的話,通常有三種命令,找了一個不錯的文章,分享一下:
https://www.jianshu.com/p/c2ec5f06cf1a
一般來說,有hard,soft,mixed,三種模式,根據(jù)不同的場景來做選擇。
最后
不說了,我準(zhǔn)備寫bug去了。