- Check whether a token is currently configured; if not, use
./assets/config.jsonthe 'username' and 'token' in to configure git
git config --global credential.helper store
Initialize the repository
- Use
git remote -vCheck whether the current remote repository exists; the remote repository is generally in the following form:
upstream https://gitcode.com/openharmony/multimedia_audio_framework (fetch)
upstream https://gitcode.com/openharmony/multimedia_audio_framework (push)
- Check whether the fork repository has been added; the fork repository format is: "https://gitcode.com/{username}/{repo}.git"其中,{username}和{repo}为`./assets/config.json`中的'username'和'token',fork仓库一般命名为origin,
If not, use
git remote addadd
Initialize the oh-gc CLI
- Refer to
./references/Readme.mdto initialize oh-gc, where the token used for login is the token from./assets/config.jsonthe token
- Determine whether the current code has updates
- Check whether the current user has already git committed; if the user has committed, then push to the remote fork repository; otherwise, help the user perform the commit operation. Note!!
git commitwhen committing, -s must be added, and "Co-Authored-By: Agent" must be added to the -m information; after committing, push to the origin fork repository - Check whether a related PR currently exists; if the current modification only modifies the code of the previous PR, then directly use
git commit --amendthen push; note to add -f; there is no need to recreate the PR,directly end the current skill. Otherwise, push and start the PR creation below - Follow the creation process: first create the ISSUE, then bind the ISSUE to the PR
Step1. Create ISSUE
// title根据当此任务以及修改确认
// body根据指定的labels选择`assets/ISSUE_TEMPLATE`中的指定模板,必须选择模板,不能自己生成,body中的内容需要进行填充,模板中的版本选择master
// labels需要和模板匹配
// repo为 owner/repo
oh-gc issue:create --repo openharmony/multimedia_audio_framework --title "test cli" --body "test cli" --labels "bug"
If creation succeeds, the following is returned: "https://gitcode.com/openharmony/multimedia_audio_framework/issues/11908" Record the "issue_id" in it as 11908
Step2. Create PR
Parameter configuration
- title needs to be confirmed according to this task and the modifications
- head is the current commit branch
- body select
assets/PR_TEMPLATE/PULL_REQUEST_TEMPLATE.zh-CN.mdand update the self-check results in the template according to the content, where theIssueNofield should be filled with the ISSUE url returned when creating the ISSUE. **General specification self-check:** The field must be filled with the self-check result according to this modification; |Y/N/NA| must select one of them to fill in - repo is owner/repo
- base is generally master
oh-gc pr:create --repo openharmony/multimedia_audio_framework --head feature --base master --title "PR标题" --body body
If creation succeeds, the following is returned: "Created PR #14486: PR title" If it fails, query whether a PR has already been created; if it exists, return it; if it does not exist, directly return the failure reason to the user and end the process.
Step3. Start build
After successfully creating the PR, ask the user whether to start the build? If the user declines, exit the process. If the user wants to, wait for the PR to fully initialize, wait 30s, and help the user start the build
oh-gc pr:comment 14486 --body "start build"
If it fails, retry; after 3 retries, if it still fails, inform the user of the failure reason and exit.