Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move .REVIEW_COMMENT_STATE to .git #36

Merged
merged 4 commits into from
Jan 22, 2021
Merged

Conversation

chitoku-k
Copy link
Collaborator

@chitoku-k chitoku-k added the enhancement New feature or request label Oct 22, 2020

let l:pr = split(system([s:script_dir . 'pr-id.sh', trim(l:owner), trim(l:name), trim(l:current_branch)]), "\n")

let l:pr = systemlist([s:script_dir . 'pr-id.sh', l:owner, l:name, l:current_branch])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

systemlist を使えば split 不要できれいになる

@@ -33,12 +28,17 @@ endfunction
function! g:goshiteki#add_review_comment() range abort
let s:add_review_comment_tempname = tempname()
let s:git_root = trim(system(['git', 'rev-parse', '--show-toplevel'])) . '/'
let s:git_dir = getenv('GIT_DIR')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GIT_DIR 対策がちょっと入ってしまった

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let s:git_dir = getenv('GIT_DIR')
let s:git_dir = getenv('GIT_DIR') || '.git'

を使うと一撃でやりたいことできそうで、下のifがいらない気がする?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vim script は || の結果が整数型になるのでそれは NG

@@ -68,8 +67,8 @@ endfunction

function! g:goshiteki#post_submit(status, tempname, pr_id) abort
let l:body = join(readfile(a:tempname), "\n")
call system([s:script_dir . 'submit-review.sh', a:pr_id, l:body, a:status, "./.REVIEW_COMMENT_STATE"])
echo "Submit review(status: " . "a:status" . ")"
call system([s:script_dir . 'submit-review.sh', a:pr_id, l:body, a:status, s:git_root . s:git_dir . '/REVIEW_COMMENT_STATE'])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.git の中なので . 始まりのファイル名もやめた

@@ -2,7 +2,7 @@

# review-comments readme.md 1 body json
review-comments() {
local REVIEW_COMMENT_STATE="./.REVIEW_COMMENT_STATE"
local REVIEW_COMMENT_STATE=$(git rev-parse --show-toplevel)/${GIT_DIR:-.git}/REVIEW_COMMENT_STATE
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

シェルスクリプト側は一行で書ける

autoload/goshiteki.vim Outdated Show resolved Hide resolved
@himanoa himanoa merged commit 0093ed9 into master Jan 22, 2021
@himanoa himanoa deleted the feat/move-review-state branch January 22, 2021 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Goshiteki のステートがカレントディレクトリーに置かれている
2 participants