定制 valantic-cec/aicommits 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

valantic-cec/aicommits

最新稳定版本:1.0.0

Composer 安装命令:

composer require valantic-cec/aicommits

包简介

Uses `git diff --staged` to generate better commit messages.

README 文档

README

Uses git diff --staged to generate better commit messages.

demo (changes in two different repositories)

Peek 2023-06-15 19-29.gif

Setup

  • composer global require valantic-cec/aicommits
  • Add OPENAI_KEY to your environment and create your own AI Git Commit command (OpenAI API Key)
    • Example for bash: adjust or create your .bashrc/.zshrc/.bashrc-personal
# Basic example (~/.bashrc or ~/.bash-personal)

# set global composer directory into path
if [ -d "$HOME/.config/composer/vendor/bin" ] ;
  then PATH="$HOME/.config/composer/vendor/bin:$PATH"
fi

# set OPENAI_KEY environment variable
export OPENAI_KEY=sk-...

# Commit everything helper function
function commit() {
  commitMessage="$*"

  git add .

  if [ "$commitMessage" = "" ]; then
    commitMessage=$(aicommits)
  fi

  # combine branchname and aicommits
  eval "git commit -a -m '${commitMessage}'"
}
# Extended example following naming conventions  (~/.bashrc or ~/.bash-personal)

# set global composer directory into path
if [ -d "$HOME/.config/composer/vendor/bin" ] ;
  then PATH="$HOME/.config/composer/vendor/bin:$PATH"
fi

# set OPENAI_KEY environment variable
export OPENAI_KEY=sk-...

# Commit everything helper function
function commit() {
  commitMessage="$*"

  git add .

  # Get the current branch name
  branch=$(git rev-parse --abbrev-ref HEAD)

  # Define the regular expression pattern for your branch naming convension
  # Example Branchname: feature/spry-1234_add_fancy_feature
  pattern="^(feature|bugfix|task|hotfix|improvement|release)/([[:alnum:]-]+)"

  # Extract the specific part using regex
  if [[ $branch =~ $pattern ]]; then
    extracted_part="${BASH_REMATCH[2]}"
  else
    extracted_part="no-task"
  fi

  if [ "$commitMessage" = "" ]; then
    commitMessage=$(aicommits)
  fi

  # combine branchname and aicommits
  eval "git commit -a -m '${extracted_part} ${commitMessage}'"
}

.zshrc example: https://github.com/valantic-CEC-Deutschland-GmbH/aicommits/blob/main/.zshrc-example

assumtions for gitlab repo configuration

  • JIRA connected
  • configured git hook following a naming convention i.e. task/jiraticket-xxxx_branch_description (#((feature|bugfix|task|hotfix|improvement|release)/jiraticket-[0-9]{1,})|master|staging|no-task/(.+)?$#i)

development usage

  • php aicommits

ToDo

perfect code, no todos, no bugs ;-)

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-19