水銀小技巧-向服務器推送時給群組成員發送郵件

之前翻譯過一系列文章,探討水銀的使用方法

進來由于工作原因,使用了 bitbucket代碼托管網站。這個網站是為數不多的支持水銀的代碼托管網站之一。經過嘗試,感覺真心不錯。里面有這么一個Service功能,可以添加各種各樣的服務。其中有一個服務,叫做Email。這個服務可以在有人給這個倉庫push代碼的時候,發送郵件給這個倉庫的訂閱者。

這的確是一個比較使用的功能。大家也不可能實時關注倉庫的動態,能夠有這種通知來提醒大家是再好不過了。那么,如果不用bitbucket的話,可不可以也有這個功能呢?通過嘗試,發現這個功能可以有。

我在Windows 7和Ubuntu上都嘗試了這個功能,其實實現起來是一模一樣的。我們要做的,只是編輯一個文件。這個文件是你倉庫下的.hg下的hgrc文件。當然,這也不是我發明的,網上有教程,只是一開始我摸索了好久都沒成功,后來也是糊里糊涂地就搞定了。

[extensions]
notify=

[hooks]
# Enable either changegroup or incoming or outgoing.
# changegroup will send one email for all incoming changesets,
# whereas incoming sends one email per incoming changeset.
# Note: Configuring both is possible, but probably not
#       what you want, you'll get one email for the group
#       and one for each changeset in the group.
# outgoing will send one email for all outgoing changesets
changegroup.notify = python:hgext.notify.hook
#incoming.notify = python:hgext.notify.hook
#outgoing.notify = python:hgext.notify.hook
[email]
from = ZhongCheng<zhongcheng0519@163.com>
method = smtp

[smtp]
host = smtp.163.com
# Optional options:
username = *******@163.com
password = *******
port = 25
# tls = smtps
tls = none
# local_hostname = me.example.com

# the baseurl is used for constructing hgweb-URLs for the mails
# It can be a dummy value if your repo isn't
# available via http
[web]
baseurl = http://hgserver/hg

[notify]
# Space separated list of change sources. Notifications are sent only
# if it includes the incoming or outgoing changes source. Incoming
# sources can be ``serve`` for changes coming from http or ssh,
# ``pull`` for pulled changes, ``unbundle`` for changes added by
# :hg:`unbundle` or ``push`` for changes being pushed
# locally. Outgoing sources are the same except for ``unbundle`` which
# is replaced by ``bundle``. Default: serve.
sources = serve push unbundle

# set this to False when you're ready for mail to start sending
test = False

# While the subscription information can be included in this file,
#   (in which case, set: config =)
# having it in a separate file allows for it to be version controlled
# and for the option of having subscribers maintain it themselves.
# config = 

[reposubs]
# key is glob pattern, value is comma-separated list of subscriber emails
* = *******@163.com,*******@163.com,**********@qq.com

# You can override the changeset template here, if you want.
# If it doesn't start with \n it may confuse the email parser.
# here's an example that makes the changeset template look more like hg log:
template =
  details:   {baseurl}/{webroot}/rev/{node|short}
  branches:  {branches}
  changeset: {rev}:{node|short}
  user:      {author}
  date:      {date|date}
  description:
  {desc}\n

# max lines of diffs to include (0=none, -1=all)
maxdiff = 300

# if you want to use a shorter repo-name, you can strip off components at the beginning.
# For example to strip off /usr/local/hg/repos from /usr/local/hg/repos/code use
# strip = 5

我這里使用的是163的smtp服務器,當然,技術好的可以自己搭一個。另外,qq的smtp服務器貌似不太好用,Gmail的smtp的端口號是587。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • Spring Cloud為開發人員提供了快速構建分布式系統中一些常見模式的工具(例如配置管理,服務發現,斷路器,智...
    卡卡羅2017閱讀 134,991評論 19 139
  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,523評論 25 708
  • 告別舊歲,邁入新年,新的一個四季輪回的時間重新獲得,而人的生命也將進入一段新的旅程。中國俗話里把“年”稱為“年關”...
    劉西洋閱讀 1,016評論 0 3