Pull Request Guide Pull Request 指南 Pull Request 指南 Pull Request Guide

A Pull Request (PR) is a way to propose changes to a project. Instead of pushing directly to the develop branch, you push your changes to a separate branch and ask your team to review them before merging. Pull Request(PR)是一種向專案提出修改建議的方式。你不會直接推送到 develop 分支,而是推送到一個獨立的分支,然後請團隊審核後再合併。 Pull Request(PR)是一种向项目提出修改建议的方式。你不会直接推送到 develop 分支,而是推送到一个独立的分支,然后请团队审核后再合并。 Ang Pull Request (PR) ay isang paraan para mag-propose ng mga pagbabago sa isang project. Sa halip na mag-push nang diretso sa develop branch, ipo-push mo ang iyong mga pagbabago sa isang hiwalay na branch at hihilingin sa iyong team na i-review bago i-merge.

Write Code寫程式写代码Sumulat ng Code </> Push Branch推送分支推送分支Push Branch Create PR建立 PR创建 PRGumawa ng PR Review審核审核Review 🔍 Merge合併合并Merge

Why use Pull Requests? 為什麼要用 Pull Request? 为什么要用 Pull Request? Bakit gumamit ng Pull Request?

  • Code review — teammates can check your code for bugs and suggest improvements 程式碼審核 — 團隊成員可以檢查你的程式碼是否有 bug,並提出改善建議 代码审核 — 团队成员可以检查你的代码是否有 bug,并提出改进建议 Code review — maaaring suriin ng mga kasamahan ang iyong code para sa mga bug at magmungkahi ng improvements
  • Discussion — leave comments on specific lines of code 討論 — 可以在特定的程式碼行上留言 讨论 — 可以在特定的代码行上留言 Diskusyon — mag-iwan ng comments sa mga partikular na linya ng code
  • History — a clear record of what changed and why 歷史記錄 — 清楚記錄了什麼改動和原因 历史记录 — 清楚记录了什么改动和原因 History — malinaw na record kung ano ang nagbago at bakit
  • Safety — prevents broken code from reaching the develop branch 安全性 — 防止有問題的程式碼進入主分支 安全性 — 防止有问题的代码进入主分支 Kaligtasan — pinipigilan ang sirang code na makapasok sa develop branch
Prerequisite: 前置條件: 前置条件: Kinakailangan: Make sure you're familiar with the Git Daily Workflow (clone, branch, commit, push) before creating a PR. 建立 PR 之前,請先熟悉 Git 日常工作流程(clone、branch、commit、push)。 创建 PR 之前,请先熟悉 Git 日常工作流程(clone、branch、commit、push)。 Bago gumawa ng PR, siguraduhing pamilyar ka sa Git Daily Workflow (clone, branch, commit, push).

Before creating a PR, make sure your branch is ready: 建立 PR 之前,確保你的分支已準備好: 创建 PR 之前,确保你的分支已准备好: Bago gumawa ng PR, siguraduhing handa na ang iyong branch:

1. Make sure all your changes are committed: 1. 確認所有改動都已 commit: 1. 确认所有改动都已 commit: 1. Siguraduhing lahat ng pagbabago ay naka-commit na:

$ git status
On branch feature/my-task
nothing to commit, working tree clean

2. Push your branch to Gitea: 2. 將你的分支推送到 Gitea: 2. 将你的分支推送到 Gitea: 2. I-push ang iyong branch sa Gitea:

$ git push -u origin feature/my-task

3. (Optional) Update your branch with the latest develop to avoid conflicts: 3.(可選)同步最新的 develop 來避免衝突: 3.(可选)同步最新的 develop 来避免冲突: 3. (Opsyonal) I-update ang iyong branch gamit ang pinakabagong develop para maiwasan ang mga conflict:

$ git pull origin develop
$ git push

Open git.datawords.hk and navigate to your repository. 打開 git.datawords.hk,進入你的 repository。 打开 git.datawords.hk,进入你的仓库。 Buksan ang git.datawords.hk at pumunta sa iyong repository.

After pushing your branch, Gitea often shows a prompt to create a PR. You can also create one manually: 推送分支後,Gitea 通常會顯示建立 PR 的提示。你也可以手動建立: 推送分支后,Gitea 通常会显示创建 PR 的提示。你也可以手动创建: Pagkatapos i-push ang iyong branch, madalas magpapakita ang Gitea ng prompt para gumawa ng PR. Maaari mo rin itong gawin nang manu-mano:

Option A: Click the prompt banner that appears after pushing: 方法 A:點擊推送後出現的提示橫幅: 方法 A:点击推送后出现的提示横幅: Option A: I-click ang prompt banner na lalabas pagkatapos mag-push:

You pushed on branch 你剛推送到分支 你刚推送到分支 Nag-push ka sa branch feature/my-task New Pull Request 新建 Pull Request 新建 Pull Request New Pull Request

Option B: Go to the repository page, click "Pull Requests" in the top menu, then click "New Pull Request". 方法 B:進入 repository 頁面,點擊頂部選單的 「Pull Requests」,再點擊 「New Pull Request」 方法 B:进入仓库页面,点击顶部菜单的 "Pull Requests",再点击 "New Pull Request" Option B: Pumunta sa repository page, i-click ang "Pull Requests" sa top menu, pagkatapos i-click ang "New Pull Request".

Fill in the PR form: 填寫 PR 表單: 填写 PR 表单: Punan ang PR form:

New Pull Request develop feature/my-task Title feat: add user login page Description 描述 描述 Paglalarawan Describe what you changed and why... 描述你改了什麼和為什麼⋯ 描述你改了什么和为什么⋯ Ilarawan kung ano ang binago at bakit... Submit Pull Request
  1. Title: A short summary of what you did (e.g. feat: add user login page) 標題:簡短總結你做了什麼(例如 feat: add user login page 标题:简短总结你做了什么(例如 feat: add user login page Title: Maikling buod ng ginawa mo (hal. feat: add user login page)
  2. Description: Explain what changed, why, and any important details reviewers should know 描述:說明改了什麼、為什麼,以及審核者需要知道的重要細節 描述:说明改了什么、为什么,以及审核者需要知道的重要细节 Description: Ipaliwanag kung ano ang nagbago, bakit, at anumang mahahalagang detalye na dapat malaman ng mga reviewer

Click "Submit Pull Request" to create it. 點擊 「Submit Pull Request」 建立 PR。 点击 "Submit Pull Request" 创建 PR。 I-click ang "Submit Pull Request" para gawin ito.

Tip: 提示: 提示: Tip: You can also assign reviewers and add labels from the right sidebar to help organize your PR. 你也可以從右側欄指定審核者和新增標籤來幫助整理你的 PR。 你也可以从右侧栏指定审核者和添加标签来帮助整理你的 PR。 Maaari ka ring mag-assign ng reviewers at magdagdag ng labels mula sa kanang sidebar para makatulong sa pag-organisa ng iyong PR.

After creating the PR, your teammates will review your changes. Here's how the review process works: 建立 PR 後,你的團隊成員會審核你的改動。以下是審核流程的運作方式: 创建 PR 后,你的团队成员会审核你的改动。以下是审核流程的运作方式: Pagkatapos gumawa ng PR, ire-review ng iyong mga kasamahan ang mga pagbabago mo. Ganito gumagana ang review process:

As a PR author 作為 PR 作者 作为 PR 作者 Bilang PR author

  • Respond to comments and questions from reviewers 回覆審核者的留言和問題 回复审核者的留言和问题 Sagutin ang mga comment at tanong ng mga reviewer
  • If changes are requested, update your code locally, commit, and push — the PR updates automatically 如果被要求修改,在本地更新程式碼、commit 並 push — PR 會自動更新 如果被要求修改,在本地更新代码、commit 并 push — PR 会自动更新 Kung may hinihinging pagbabago, i-update ang code mo nang lokal, mag-commit, at mag-push — awtomatikong mag-a-update ang PR
# Make requested changes, then:
$ git add .
$ git commit -m "fix: address review feedback"
$ git push

As a reviewer 作為審核者 作为审核者 Bilang reviewer

  • Go to the PR page and click the "Files Changed" tab to see all changes 進入 PR 頁面,點擊 「Files Changed」 分頁查看所有改動 进入 PR 页面,点击 "Files Changed" 标签页查看所有改动 Pumunta sa PR page at i-click ang "Files Changed" tab para makita ang lahat ng pagbabago
  • Click on any line to leave a comment 點擊任一行即可留言 点击任一行即可留言 I-click ang anumang linya para mag-iwan ng comment
  • When done, click "Submit Review" and choose: Approve, Request Changes, or Comment 完成後,點擊 「Submit Review」,選擇:Approve(批准)、Request Changes(要求修改)或 Comment(留言) 完成后,点击 "Submit Review",选择:Approve(批准)、Request Changes(要求修改)或 Comment(留言) Kapag tapos na, i-click ang "Submit Review" at piliin: Approve, Request Changes, o Comment
Tip: 提示: 提示: Tip: Be constructive in reviews. Focus on the code, not the person. Explain why something should change, not just what to change. 審核時要有建設性。關注程式碼而非人。說明為什麼需要修改,而非只說要改什麼 审核时要有建设性。关注代码而非人。说明为什么需要修改,而非只说要改什么 Maging constructive sa mga review. Mag-focus sa code, hindi sa tao. Ipaliwanag bakit kailangang baguhin, hindi lang ano ang babaguhin.

Once the PR is approved, it's time to merge your changes into develop. PR 被批准後,就可以將你的改動合併到 develop 了。 PR 被批准后,就可以将你的改动合并到 develop 了。 Kapag na-approve na ang PR, oras na para i-merge ang iyong mga pagbabago sa develop.

On the PR page, scroll down to find the merge button: 在 PR 頁面向下捲動找到合併按鈕: 在 PR 页面向下滚动找到合并按钮: Sa PR page, mag-scroll pababa para mahanap ang merge button:

Approved 已批准 已批准 Na-approve 1 approving review 1 個批准審核 1 个批准审核 1 approving review Merge Pull Request 合併 Pull Request 合并 Pull Request I-merge ang Pull Request

Gitea offers several merge strategies. The most common ones are: Gitea 提供幾種合併策略。最常用的有: Gitea 提供几种合并策略。最常用的有: Nag-aalok ang Gitea ng ilang merge strategies. Ang pinakakaraniwan ay:

  • Merge Commit — keeps all individual commits (default, recommended) Merge Commit — 保留所有個別 commit(預設,推薦) Merge Commit — 保留所有单独 commit(默认,推荐) Merge Commit — pinapanatili ang lahat ng individual commits (default, inirerekomenda)
  • Squash Merge — combines all commits into one (cleaner history) Squash Merge — 將所有 commit 合併為一個(更整潔的歷史) Squash Merge — 将所有 commit 合并为一个(更整洁的历史) Squash Merge — pinagsasama lahat ng commits sa isa (mas malinis na history)
Important: 重要: 重要: Mahalaga: If there are merge conflicts, Gitea will ask you to resolve them before merging. You can do this locally by pulling develop into your branch, resolving conflicts, and pushing again. 如果有合併衝突,Gitea 會要求你先解決才能合併。你可以在本地將 develop 拉取到你的分支、解決衝突後再推送。 如果有合并冲突,Gitea 会要求你先解决才能合并。你可以在本地将 develop 拉取到你的分支、解决冲突后再推送。 Kung may merge conflicts, hihilingin ng Gitea na i-resolve ang mga ito bago mag-merge. Maaari mo itong gawin nang lokal sa pamamagitan ng pag-pull ng develop sa iyong branch, pag-resolve ng conflicts, at muling pag-push.

Deployment 部署 部署 Deployment

Merging into certain branches triggers automatic deployment via Gitea Actions: 合併到特定分支會透過 Gitea Actions 自動部署 合并到特定分支会通过 Gitea Actions 自动部署 Ang pag-merge sa ilang branches ay nagti-trigger ng automatic deployment sa pamamagitan ng Gitea Actions:

develop Integration整合集成Integration staging Staging envStaging 環境Staging 环境Staging env master Production envProduction 環境Production 环境Production env No auto-deploy不自動部署不自动部署Walang auto-deploy Auto-deploy to staging自動部署到 staging自动部署到 stagingAuto-deploy sa staging (if available)(如有)(如有)(kung meron) Auto-deploy to production自動部署到 production自动部署到 productionAuto-deploy sa production
Note: 注意: 注意: Paalala: Not all projects have a staging environment. Check with your team lead if unsure which branches trigger deployments for your project. 並非所有專案都有 staging 環境。如果不確定你的專案哪些分支會觸發部署,請向團隊負責人確認。 并非所有项目都有 staging 环境。如果不确定你的项目哪些分支会触发部署,请向团队负责人确认。 Hindi lahat ng project ay may staging environment. Magtanong sa iyong team lead kung hindi sigurado kung aling mga branch ang nagti-trigger ng deployment sa iyong project.

When a deployment is triggered, Gitea Actions runs the build automatically. You can check the build status and logs in the Actions tab of your repository. 當觸發部署時,Gitea Actions 會自動執行建置。你可以在 repository 的 Actions 分頁查看建置狀態和日誌。 当触发部署时,Gitea Actions 会自动执行构建。你可以在仓库的 Actions 标签页查看构建状态和日志。 Kapag na-trigger ang deployment, awtomatikong tatakbo ang build sa pamamagitan ng Gitea Actions. Maaari mong i-check ang build status at logs sa Actions tab ng iyong repository.

Finding the Actions tab 找到 Actions 分頁 找到 Actions 标签页 Paghahanap ng Actions tab

Go to your repository on Gitea and click "Actions" in the top navigation bar (next to Pull Requests, Packages, etc.): 前往 Gitea 上的 repository,點擊頂部導覽列的 「Actions」(在 Pull Requests、Packages 旁邊): 前往 Gitea 上的仓库,点击顶部导航栏的 "Actions"(在 Pull Requests、Packages 旁边): Pumunta sa iyong repository sa Gitea at i-click ang "Actions" sa top navigation bar (katabi ng Pull Requests, Packages, atbp.):

Code Issues Pull Requests Actions Packages Settings

Workflow runs list 工作流程執行列表 工作流程执行列表 Listahan ng workflow runs

The Actions page shows a list of all workflow runs. You can filter by workflow name, status, or who triggered the run: Actions 頁面會顯示所有工作流程執行記錄。你可以按工作流程名稱、狀態或觸發者篩選: Actions 页面会显示所有工作流程执行记录。你可以按工作流程名称、状态或触发者筛选: Ang Actions page ay nagpapakita ng listahan ng lahat ng workflow runs. Maaari kang mag-filter ayon sa workflow name, status, o kung sino ang nag-trigger:

All Workflows ▾ All Status ▾ Deploy to production master — pushed by johndoe — 2m ago Success成功成功Success Deploy to staging staging — pushed by janedoe — 15m ago Failure失敗失败Failure Build and test develop — pushed by janedoe — 1m ago Running執行中运行中Tumatakbo

↑ The Actions tab shows each workflow run with its status, branch, and who triggered it ↑ Actions 分頁顯示每次工作流程執行的狀態、分支和觸發者 ↑ Actions 标签页显示每次工作流程执行的状态、分支和触发者 ↑ Ipinapakita ng Actions tab ang bawat workflow run kasama ang status, branch, at kung sino ang nag-trigger

Viewing build logs 查看建置日誌 查看构建日志 Pagtingin sa build logs

Click on any workflow run to open the detail page. Here you can see: 點擊任意一次執行即可打開詳情頁面。你可以看到: 点击任意一次执行即可打开详情页面。你可以看到: I-click ang anumang workflow run para buksan ang detail page. Makikita mo:

  • Job list on the left — each job shows its own status 左側的任務列表 — 每個任務顯示自己的狀態 左侧的任务列表 — 每个任务显示自己的状态 Job list sa kaliwa — bawat job ay may sariling status
  • Step-by-step logs on the right — click any step to expand its log output 右側的逐步日誌 — 點擊任何步驟即可展開日誌輸出 右侧的逐步日志 — 点击任何步骤即可展开日志输出 Step-by-step na logs sa kanan — i-click ang anumang step para i-expand ang log output
  • Re-run button — retry a failed build without pushing new code Re-run 按鈕 — 無需推送新程式碼即可重試失敗的建置 Re-run 按钮 — 无需推送新代码即可重试失败的构建 Re-run button — i-retry ang nabigong build nang hindi nag-push ng bagong code
Deploy to staging staging — abc1234 — janedoe Re-run all Jobs build-and-deploy Steps Set up job 2s Checkout code 5s Build 18s Deploy skipped已跳過已跳过nilaktawan

↑ The run detail page shows jobs on the left and step-by-step logs on the right. Click a failed step to see the error. ↑ 執行詳情頁面左側顯示任務,右側顯示逐步日誌。點擊失敗的步驟即可查看錯誤。 ↑ 执行详情页面左侧显示任务,右侧显示逐步日志。点击失败的步骤即可查看错误。 ↑ Ang run detail page ay nagpapakita ng jobs sa kaliwa at step-by-step logs sa kanan. I-click ang nabigong step para makita ang error.

Build failed? 建置失敗? 构建失败? Nabigo ang build? Click the failed step (highlighted in red) to expand the log and find the error. Common causes: syntax errors, missing dependencies, or failing tests. Fix the issue on your branch, commit, and push — the build will re-run automatically. You can also click "Re-run all" to retry without pushing new code. 點擊失敗的步驟(紅色高亮)展開日誌找出錯誤。常見原因:語法錯誤、缺少依賴、或測試失敗。在你的分支上修復問題、commit 並 push — 建置會自動重新執行。你也可以點擊 「Re-run all」 不推送新程式碼直接重試。 点击失败的步骤(红色高亮)展开日志找出错误。常见原因:语法错误、缺少依赖、或测试失败。在你的分支上修复问题、commit 并 push — 构建会自动重新执行。你也可以点击 "Re-run all" 不推送新代码直接重试。 I-click ang nabigong step (naka-highlight sa pula) para i-expand ang log at hanapin ang error. Karaniwang dahilan: syntax errors, kulang na dependencies, o nabigong tests. Ayusin ang problema sa iyong branch, mag-commit, at mag-push — awtomatikong uulit ang build. Maaari mo ring i-click ang "Re-run all" para mag-retry nang hindi nag-push ng bagong code.

If a deployment causes problems, you can roll back by reverting the merge commit. This creates a new commit that undoes the changes, which triggers a fresh deployment of the corrected state. 如果部署導致問題,你可以透過還原(revert)合併 commit 來回滾。這會建立一個新 commit 撤銷改動,從而觸發修正版本的重新部署。 如果部署导致问题,你可以通过还原(revert)合并 commit 来回滚。这会创建一个新 commit 撤销改动,从而触发修正版本的重新部署。 Kung nagdulot ng problema ang deployment, maaari kang mag-rollback sa pamamagitan ng pag-revert ng merge commit. Gagawa ito ng bagong commit na nag-a-undo ng mga pagbabago, na magti-trigger ng bagong deployment ng naayos na estado.

Note: 注意: 注意: Paalala: Gitea does not have a "Revert" button in the web UI (unlike GitHub). You need to use the command line. Gitea 的網頁介面沒有「Revert」按鈕(不像 GitHub)。你需要使用命令列操作。 Gitea 的网页界面没有「Revert」按钮(不像 GitHub)。你需要使用命令行操作。 Walang "Revert" button ang Gitea sa web UI (hindi katulad ng GitHub). Kailangan mong gamitin ang command line.

Step 1: Find the merge commit hash 步驟一:找到合併 commit 的 hash 步骤一:找到合并 commit 的 hash Step 1: Hanapin ang merge commit hash

On Gitea, go to the merged PR page. The merge commit hash is shown at the bottom of the PR conversation, in the merge message (e.g. "merged commit abc1234 into master"). You can also find it in the branch's commit history. 在 Gitea 上進入已合併的 PR 頁面。合併 commit 的 hash 會顯示在 PR 對話底部的合併訊息中(例如 「merged commit abc1234 into master」)。你也可以在分支的 commit 歷史中找到。 在 Gitea 上进入已合并的 PR 页面。合并 commit 的 hash 会显示在 PR 对话底部的合并消息中(例如 "merged commit abc1234 into master")。你也可以在分支的 commit 历史中找到。 Sa Gitea, pumunta sa merged PR page. Ang merge commit hash ay makikita sa ibaba ng PR conversation, sa merge message (hal. "merged commit abc1234 into master"). Mahahanap mo rin ito sa commit history ng branch.

Step 2: Revert the merge commit 步驟二:還原合併 commit 步骤二:还原合并 commit Step 2: I-revert ang merge commit

# Example: rollback on master (production)
$ git checkout master
$ git pull
$ git revert -m 1 abc1234
$ git push
# Example: rollback on staging
$ git checkout staging
$ git pull
$ git revert -m 1 abc1234
$ git push
What does -m 1 mean? -m 1 是什麼意思? -m 1 是什么意思? Ano ang ibig sabihin ng -m 1? A merge commit has two parents. -m 1 tells Git to keep the first parent (the branch you merged into, e.g. master) and undo the second parent (the feature branch changes). This is always what you want when reverting a merge. 合併 commit 有兩個父 commit。-m 1 告訴 Git 保留第一個父 commit(你合併進去的分支,例如 master),撤銷第二個父 commit(功能分支的改動)。還原合併時一律使用這個參數。 合并 commit 有两个父 commit。-m 1 告诉 Git 保留第一个父 commit(你合并进去的分支,例如 master),撤销第二个父 commit(功能分支的改动)。还原合并时一律使用这个参数。 Ang merge commit ay may dalawang parents. Sinasabi ng -m 1 sa Git na panatilihin ang unang parent (ang branch na pinag-merge-an, hal. master) at i-undo ang pangalawang parent (ang feature branch changes). Ito ang laging kailangan kapag nagri-revert ng merge.

Step 3: Verify 步驟三:確認 步骤三:确认 Step 3: I-verify

After pushing the revert commit, Gitea Actions will automatically build and deploy the corrected version. Check the Actions tab to confirm the deployment succeeded. 推送 revert commit 後,Gitea Actions 會自動建置並部署修正版本。查看 Actions 分頁確認部署成功。 推送 revert commit 后,Gitea Actions 会自动构建并部署修正版本。查看 Actions 标签页确认部署成功。 Pagkatapos i-push ang revert commit, awtomatikong magbi-build at magde-deploy ang Gitea Actions ng naayos na version. I-check ang Actions tab para i-confirm na nagtagumpay ang deployment.

After merging, clean up by deleting the feature branch: 合併後,刪除功能分支進行清理: 合并后,删除功能分支进行清理: Pagkatapos mag-merge, mag-clean up sa pamamagitan ng pag-delete ng feature branch:

On Gitea: After merging, Gitea shows a "Delete Branch" button. Click it to remove the remote branch. 在 Gitea 上:合併後,Gitea 會顯示 「Delete Branch」 按鈕。點擊即可刪除遠端分支。 在 Gitea 上:合并后,Gitea 会显示 "Delete Branch" 按钮。点击即可删除远端分支。 Sa Gitea: Pagkatapos mag-merge, magpapakita ang Gitea ng "Delete Branch" button. I-click ito para alisin ang remote branch.

On your computer: Switch back to develop, pull the merged changes, and delete the local branch: 在你的電腦上:切回 develop,拉取已合併的改動,並刪除本地分支: 在你的电脑上:切回 develop,拉取已合并的改动,并删除本地分支: Sa iyong computer: Bumalik sa develop, i-pull ang mga naka-merge na pagbabago, at i-delete ang local branch:

$ git checkout develop
$ git pull
$ git branch -d feature/my-task
Tip: 提示: 提示: Tip: The -d flag only deletes the branch if it has been merged. This is a safe operation. If you see an error, it means the branch hasn't been merged yet. -d 參數只會刪除已合併的分支,這是安全的操作。如果你看到錯誤,表示該分支尚未合併。 -d 参数只会删除已合并的分支,这是安全的操作。如果你看到错误,表示该分支尚未合并。 Ang -d flag ay nagde-delete lang ng branch kung ito ay naka-merge na. Ito ay ligtas na operasyon. Kung may error, ibig sabihin hindi pa naka-merge ang branch.

That's the full PR cycle! 完整的 PR 流程就是這樣! 完整的 PR 流程就是这样! Iyon na ang buong PR cycle!

Create a branch → make changes → push → create PR → get reviewed → merge → clean up. Repeat for every task! 建立分支 → 修改 → 推送 → 建立 PR → 審核 → 合併 → 清理。每個任務重複這個流程! 创建分支 → 修改 → 推送 → 创建 PR → 审核 → 合并 → 清理。每个任务重复这个流程! Gumawa ng branch → gumawa ng pagbabago → push → gumawa ng PR → ma-review → merge → linisin. Ulitin para sa bawat task!