ruby 将体式任务/ ids拉入git commit消息文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 将体式任务/ ids拉入git commit消息文件相关的知识,希望对你有一定的参考价值。

require 'asana'

access_token = '12345678'
project_id = 12345678 # find this in your URL
user_id = 12345678 # found this by right clicking on my avatar in asana and inspecting element - it's in the URL there
COMMENT_CHAR = '#' # replace with your editor's comment character(s)

client = Asana::Client.new do |c|
	c.authentication :access_token, access_token
end

tasks = client.tasks.find_by_project(projectId: project_id, options: { fields: ['name', 'id', 'assignee'] })

gitmsg = "\n\n"
first = true
tasks.each do |task|
	# only find tasks starting with a number in square brackets, that isn't set to zero
	if (task.name =~ /[\d]/) && (!task.name.include? "[0]")
		if task.assignee && task.assignee['id'] == user_id
			# the first task (top most in Asana UI) is prefixed with a dot so it's not commented out (I use vim for commit messages)
			if first 
				first = false
				gitmsg += "."
			end
			gitmsg += COMMENT_CHAR + task.id.to_s + "    " + COMMENT_CHAR + task.name + "\n"
		end
	end
end

File.open('.git/.gitmsg', 'w') { |file|
	file.write(gitmsg)
}

以上是关于ruby 将体式任务/ ids拉入git commit消息文件的主要内容,如果未能解决你的问题,请参考以下文章

Git拉入错误的分支

最佳实践 - Git + 构建自动化 - 将配置分开

ruby 使用rake任务管理Rails应用程序版本号(包括git-flow支持)

ruby active_dispatch_http_upload_file_emulation与Net :: HTTP :: Persistent连接并通过http拉入文件。

用 Git 设置常春藤?

链接脚本与重定位