Commit Phabricator Revision to GitHub

Summarized workflow from LLVM documentation. Just keep this as a checklist for future commits. In this passage, I will use D102669 as an example to show the entire commit procedure. Since the commit is done on the patch branch. Let’s start by checking out the branch.

1. Check out the patch branch.

> git checkout D102669

2. Update commit message. Go to the Phabricator page of D102669. Copy the revision title as the header of the commit message. Then, on the option-menu to the right, select Edit Revision. Copy the revision summary as the body of the commit message. Remember to add a blank line after the header. Finally, add the revision link as the last line.

Go to the Phabricator page of D102669. On the option menu to the right, select Edit Revision.

3. Rebase the patch onto the latest commit on GitHub and then rerun the test cases locally.

> git pull --rebase origin main
> ninja check-clang-analysis

4. Re-check the list of commits to be pushed.

> git log origin/main...HEAD

5. Push the commit.

git push origin HEAD:main

As a first-time committer, the push operation was rejected twice before it was finally committed. First, GitHub requires the git push operation cannot be authenticated via username and password. Therefore, I replaced the remote link with the SSH link to solve the problem.

Username for 'https://github.com': Snape3058 
Password for 'https://[email protected]': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. 
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information. 
fatal: Authentication failed for 'https://github.com/llvm/llvm-project.git/'

Second, when you set your Emails private, GitHub will reject the pushing requirement if the operation will leak your Email address. Therefore, you need to uncheck the option to allow this operation.

remote: Resolving deltas: 100% (21/21), completed with 21 local objects.                                                                                                                                             
remote: error: GH007: Your push would publish a private email address.                                                                                                                                               
remote: You can make your email public or disable this protection by visiting:                                                                                                                                       
remote: http://github.com/settings/emails                                                                                                                                                                            
To github.com:llvm/llvm-project.git                                                                                                                                                                                  
 ! [remote rejected]           HEAD -> main (push declined due to email privacy restrictions)                                                                                                                        
error: failed to push some refs to '[email protected]:llvm/llvm-project.git'

That’s all for my first commit to GitHub for the LLVM project. Hope it would be helpful to my future commits and other contributors.

References:

1. https://llvm.org/docs/DeveloperPolicy.html#commit-messages
2. https://www.llvm.org/docs/Phabricator.html#committing-a-change
3. https://www.llvm.org/docs/GettingStarted.html#commit-from-git

从 GitHub 下载一个 Repo 中部分文件内的代码

當需要下載 GitHub 上某一個 Repo 中某個子文件夾中的內容時,可以借用 GitHub 提供的 SVN 支持來實現這一功能。

由於一些大工程中某些組件完全可以獨立使用(比如:LLVM-Lit),這種情況下如果採用完整 clone 整個 repo 然後取出其中所需的部分然後刪掉剩下的部分的方式來處理的話,未免顯得會有些有病。「如果能只下載所需要的這部分就好了!」

比如,需要從 LLVM 的 repo 中下載 LLVM-Lit 的代碼(位於:https://github.com/llvm/llvm-project/tree/main/llvm/utils/lit),則可以執行如下操作。

svn export https://github.com/llvm/llvm-project/trunk/llvm/utils/lit

此時,即可將該 repo 最新 commit 中 llvm/utils/lit 文件夾下的全部內容都獲取到當前目錄下的 lit 文件夾中了。需要注意的是這個 svn 的鏈接與在 GitHub 上瀏覽時瀏覽器中的鏈接並不是相同的。

引用:

  1. https://coderwall.com/p/o2fasg/how-to-download-a-project-subdirectory-from-github
  2. https://docs.github.com/en/github/importing-your-projects-to-github/support-for-subversion-clients