bitbucket.py 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. COMPARE_COMMITS_EXAMPLE = b"""{
  2. "pagelen": 30,
  3. "values":
  4. [{"hash": "e18e4e72de0d824edfbe0d73efe34cbd0d01d301",
  5. "repository": {"links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs"}, "html": {"href": "https://bitbucket.org/sentryuser/newsdiffs"}, "avatar": {"href": "https://bitbucket.org/sentryuser/newsdiffs/avatar/32/"}}, "type": "repository", "name": "newsdiffs", "full_name": "sentryuser/newsdiffs", "uuid": "{c78dfb25-7882-4550-97b1-4e0d38f32859}"}, "links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/e18e4e72de0d824edfbe0d73efe34cbd0d01d301"}, "comments": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/e18e4e72de0d824edfbe0d73efe34cbd0d01d301/comments"}, "patch": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/patch/e18e4e72de0d824edfbe0d73efe34cbd0d01d301"}, "html": {"href": "https://bitbucket.org/sentryuser/newsdiffs/commits/e18e4e72de0d824edfbe0d73efe34cbd0d01d301"}, "diff": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/diff/e18e4e72de0d824edfbe0d73efe34cbd0d01d301"}, "approve": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/e18e4e72de0d824edfbe0d73efe34cbd0d01d301/approve"}, "statuses": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/e18e4e72de0d824edfbe0d73efe34cbd0d01d301/statuses"}},
  6. "author": {
  7. "raw": "Sentry User <sentryuser@getsentry.com>",
  8. "type": "author"
  9. },
  10. "parents": [{"hash": "26de9b63d09aa9c787e899f149c672023e292925", "type": "commit", "links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/26de9b63d09aa9c787e899f149c672023e292925"}, "html": {"href": "https://bitbucket.org/sentryuser/newsdiffs/commits/26de9b63d09aa9c787e899f149c672023e292925"}}}], "date": "2017-05-16T23:21:40+00:00", "message": "README.md edited online with Bitbucket", "type": "commit"}],
  11. "next": "https://api.bitbucket.org/2.0/repositories/sentryuser/sentryrepo/commits/e18e4e72de0d824edfbe0d73efe34cbd0d01d301?page=2"
  12. }
  13. """
  14. GET_LAST_COMMITS_EXAMPLE = b"""{
  15. "pagelen": 30,
  16. "values":
  17. [{"hash": "e18e4e72de0d824edfbe0d73efe34cbd0d01d301",
  18. "repository": {"links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs"}, "html": {"href": "https://bitbucket.org/sentryuser/newsdiffs"}, "avatar": {"href": "https://bitbucket.org/sentryuser/newsdiffs/avatar/32/"}}, "type": "repository", "name": "newsdiffs", "full_name": "sentryuser/newsdiffs", "uuid": "{c78dfb25-7882-4550-97b1-4e0d38f32859}"}, "links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/e18e4e72de0d824edfbe0d73efe34cbd0d01d301"}, "comments": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/e18e4e72de0d824edfbe0d73efe34cbd0d01d301/comments"}, "patch": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/patch/e18e4e72de0d824edfbe0d73efe34cbd0d01d301"}, "html": {"href": "https://bitbucket.org/sentryuser/newsdiffs/commits/e18e4e72de0d824edfbe0d73efe34cbd0d01d301"}, "diff": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/diff/e18e4e72de0d824edfbe0d73efe34cbd0d01d301"}, "approve": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/e18e4e72de0d824edfbe0d73efe34cbd0d01d301/approve"}, "statuses": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/e18e4e72de0d824edfbe0d73efe34cbd0d01d301/statuses"}}, "author": {"raw": "Sentry User <sentryuser@getsentry.com>", "type": "author", "user": {"username": "sentryuser", "display_name": "Sentry User", "type": "user", "uuid": "{b128e0f6-196a-4dde-b72d-f42abc6dc239}", "links": {"self": {"href": "https://api.bitbucket.org/2.0/users/sentryuser"}, "html": {"href": "https://bitbucket.org/sentryuser/"}, "avatar": {"href": "https://bitbucket.org/account/sentryuser/avatar/32/"}}}}, "parents": [{"hash": "26de9b63d09aa9c787e899f149c672023e292925", "type": "commit", "links": {"self": {"href": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commit/26de9b63d09aa9c787e899f149c672023e292925"}, "html": {"href": "https://bitbucket.org/sentryuser/newsdiffs/commits/26de9b63d09aa9c787e899f149c672023e292925"}}}], "date": "2017-05-16T23:21:40+00:00", "message": "README.md edited online with Bitbucket", "type": "commit"}],
  19. "next": "https://api.bitbucket.org/2.0/repositories/sentryuser/newsdiffs/commits/e18e4e72de0d824edfbe0d73efe34cbd0d01d301?page=2"
  20. }
  21. """
  22. COMMIT_DIFF_PATCH = rb"""diff --git a/README.md b/README.md
  23. index 89821ce..9e09a8a 100644
  24. --- a/README.md
  25. +++ b/README.md
  26. @@ -1 +1 @@
  27. -A twitter bot to when words are said by the NYT for the first time.
  28. \ No newline at end of file
  29. +A twitter bot to when words are said by the NYT for the first time.sdfsdf
  30. \ No newline at end of file"""
  31. PUSH_EVENT_EXAMPLE = b"""{
  32. "push": {
  33. "changes": [
  34. {
  35. "links": {
  36. "html": {
  37. "href": "https://bitbucket.org/maxbittker/newsdiffs/branches/compare/e0e377d186e4f0e937bdb487a23384fe002df649..8f5952f4dcffd7b311181d48eb0394b0cca21410"
  38. },
  39. "commits": {
  40. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commits?include=e0e377d186e4f0e937bdb487a23384fe002df649&exclude=8f5952f4dcffd7b311181d48eb0394b0cca21410"
  41. },
  42. "diff": {
  43. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/diff/e0e377d186e4f0e937bdb487a23384fe002df649..8f5952f4dcffd7b311181d48eb0394b0cca21410"
  44. }
  45. },
  46. "commits": [
  47. {
  48. "links": {
  49. "approve": {
  50. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/e0e377d186e4f0e937bdb487a23384fe002df649/approve"
  51. },
  52. "statuses": {
  53. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/e0e377d186e4f0e937bdb487a23384fe002df649/statuses"
  54. },
  55. "comments": {
  56. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/e0e377d186e4f0e937bdb487a23384fe002df649/comments"
  57. },
  58. "self": {
  59. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/e0e377d186e4f0e937bdb487a23384fe002df649"
  60. },
  61. "patch": {
  62. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/patch/e0e377d186e4f0e937bdb487a23384fe002df649"
  63. },
  64. "html": {
  65. "href": "https://bitbucket.org/maxbittker/newsdiffs/commits/e0e377d186e4f0e937bdb487a23384fe002df649"
  66. },
  67. "diff": {
  68. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/diff/e0e377d186e4f0e937bdb487a23384fe002df649"
  69. }
  70. },
  71. "date": "2017-05-24T01:05:47+00:00",
  72. "hash": "e0e377d186e4f0e937bdb487a23384fe002df649",
  73. "parents": [
  74. {
  75. "type": "commit",
  76. "links": {
  77. "html": {
  78. "href": "https://bitbucket.org/maxbittker/newsdiffs/commits/8f5952f4dcffd7b311181d48eb0394b0cca21410"
  79. },
  80. "self": {
  81. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/8f5952f4dcffd7b311181d48eb0394b0cca21410"
  82. }
  83. },
  84. "hash": "8f5952f4dcffd7b311181d48eb0394b0cca21410"
  85. }
  86. ],
  87. "type": "commit",
  88. "message": "README.md edited online with Bitbucket",
  89. "author": {
  90. "type": "author",
  91. "user": {
  92. "type": "user",
  93. "display_name": "Max Bittker",
  94. "uuid": "{b128e0f6-196a-4dde-b72d-f42abc6dc239}",
  95. "username": "maxbittker",
  96. "links": {
  97. "html": {
  98. "href": "https://bitbucket.org/maxbittker/"
  99. },
  100. "avatar": {
  101. "href": "https://bitbucket.org/account/maxbittker/avatar/32/"
  102. },
  103. "self": {
  104. "href": "https://api.bitbucket.org/2.0/users/maxbittker"
  105. }
  106. }
  107. },
  108. "raw": "Max Bittker <max@getsentry.com>"
  109. }
  110. }
  111. ],
  112. "old": {
  113. "type": "branch",
  114. "links": {
  115. "html": {
  116. "href": "https://bitbucket.org/maxbittker/newsdiffs/branch/master"
  117. },
  118. "commits": {
  119. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commits/master"
  120. },
  121. "self": {
  122. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/refs/branches/master"
  123. }
  124. },
  125. "target": {
  126. "links": {
  127. "html": {
  128. "href": "https://bitbucket.org/maxbittker/newsdiffs/commits/8f5952f4dcffd7b311181d48eb0394b0cca21410"
  129. },
  130. "self": {
  131. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/8f5952f4dcffd7b311181d48eb0394b0cca21410"
  132. }
  133. },
  134. "date": "2017-05-19T22:53:22+00:00",
  135. "hash": "8f5952f4dcffd7b311181d48eb0394b0cca21410",
  136. "parents": [
  137. {
  138. "type": "commit",
  139. "links": {
  140. "html": {
  141. "href": "https://bitbucket.org/maxbittker/newsdiffs/commits/1cdfa36e62e615cdc73a1d5fcff1c706965b186d"
  142. },
  143. "self": {
  144. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/1cdfa36e62e615cdc73a1d5fcff1c706965b186d"
  145. }
  146. },
  147. "hash": "1cdfa36e62e615cdc73a1d5fcff1c706965b186d"
  148. }
  149. ],
  150. "type": "commit",
  151. "message": "README.md edited online with Bitbucket",
  152. "author": {
  153. "type": "author",
  154. "raw": "Max Bittker <max@getsentry.com>"
  155. }
  156. },
  157. "name": "master"
  158. },
  159. "truncated": false,
  160. "new": {
  161. "type": "branch",
  162. "links": {
  163. "html": {
  164. "href": "https://bitbucket.org/maxbittker/newsdiffs/branch/master"
  165. },
  166. "commits": {
  167. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commits/master"
  168. },
  169. "self": {
  170. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/refs/branches/master"
  171. }
  172. },
  173. "target": {
  174. "links": {
  175. "html": {
  176. "href": "https://bitbucket.org/maxbittker/newsdiffs/commits/e0e377d186e4f0e937bdb487a23384fe002df649"
  177. },
  178. "self": {
  179. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/e0e377d186e4f0e937bdb487a23384fe002df649"
  180. }
  181. },
  182. "date": "2017-05-24T01:05:47+00:00",
  183. "hash": "e0e377d186e4f0e937bdb487a23384fe002df649",
  184. "parents": [
  185. {
  186. "type": "commit",
  187. "links": {
  188. "html": {
  189. "href": "https://bitbucket.org/maxbittker/newsdiffs/commits/8f5952f4dcffd7b311181d48eb0394b0cca21410"
  190. },
  191. "self": {
  192. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs/commit/8f5952f4dcffd7b311181d48eb0394b0cca21410"
  193. }
  194. },
  195. "hash": "8f5952f4dcffd7b311181d48eb0394b0cca21410"
  196. }
  197. ],
  198. "type": "commit",
  199. "message": "README.md edited online with Bitbucket",
  200. "author": {
  201. "type": "author",
  202. "raw": "Max Bittker <max@getsentry.com>"
  203. }
  204. },
  205. "name": "master"
  206. },
  207. "created": false,
  208. "forced": false,
  209. "closed": false
  210. }
  211. ]
  212. },
  213. "repository": {
  214. "links": {
  215. "html": {
  216. "href": "https://bitbucket.org/maxbittker/newsdiffs"
  217. },
  218. "avatar": {
  219. "href": "https://bitbucket.org/maxbittker/newsdiffs/avatar/32/"
  220. },
  221. "self": {
  222. "href": "https://api.bitbucket.org/2.0/repositories/maxbittker/newsdiffs"
  223. }
  224. },
  225. "full_name": "maxbittker/newsdiffs",
  226. "scm": "git",
  227. "uuid": "{c78dfb25-7882-4550-97b1-4e0d38f32859}",
  228. "type": "repository",
  229. "is_private": false,
  230. "owner": {
  231. "type": "user",
  232. "display_name": "Max Bittker",
  233. "uuid": "{b128e0f6-196a-4dde-b72d-f42abc6dc239}",
  234. "username": "maxbittker",
  235. "links": {
  236. "html": {
  237. "href": "https://bitbucket.org/maxbittker/"
  238. },
  239. "avatar": {
  240. "href": "https://bitbucket.org/account/maxbittker/avatar/32/"
  241. },
  242. "self": {
  243. "href": "https://api.bitbucket.org/2.0/users/maxbittker"
  244. }
  245. }
  246. },
  247. "name": "newsdiffs",
  248. "website": ""
  249. },
  250. "actor": {
  251. "type": "user",
  252. "display_name": "Max Bittker",
  253. "uuid": "{b128e0f6-196a-4dde-b72d-f42abc6dc239}",
  254. "username": "maxbittker",
  255. "links": {
  256. "html": {
  257. "href": "https://bitbucket.org/maxbittker/"
  258. },
  259. "avatar": {
  260. "href": "https://bitbucket.org/account/maxbittker/avatar/32/"
  261. },
  262. "self": {
  263. "href": "https://api.bitbucket.org/2.0/users/maxbittker"
  264. }
  265. }
  266. }
  267. }
  268. """
  269. REPO = {
  270. "scm": "git",
  271. "website": "",
  272. "has_wiki": True,
  273. "description": "",
  274. "links": {
  275. "watchers": {
  276. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/watchers"
  277. },
  278. "branches": {
  279. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/refs/branches"
  280. },
  281. "tags": {
  282. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/refs/tags"
  283. },
  284. "commits": {
  285. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/commits"
  286. },
  287. "clone": [
  288. {
  289. "href": "https://laurynsentry@bitbucket.org/laurynsentry/helloworld.git",
  290. "name": "https",
  291. },
  292. {"href": "git@bitbucket.org:laurynsentry/helloworld.git", "name": "ssh"},
  293. ],
  294. "self": {"href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld"},
  295. "source": {
  296. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/src"
  297. },
  298. "html": {"href": "https://bitbucket.org/laurynsentry/helloworld"},
  299. "avatar": {
  300. "href": "https://bytebucket.org/ravatar/%7B2a47ac11-098a-4054-8496-193754cae14b%7D?ts=default"
  301. },
  302. "hooks": {
  303. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/hooks"
  304. },
  305. "forks": {
  306. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/forks"
  307. },
  308. "downloads": {
  309. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/downloads"
  310. },
  311. "issues": {
  312. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/issues"
  313. },
  314. "pullrequests": {
  315. "href": "https://api.bitbucket.org/2.0/repositories/laurynsentry/helloworld/pullrequests"
  316. },
  317. },
  318. "created_on": "2018-05-14T23:53:37.377674+00:00",
  319. "full_name": "laurynsentry/helloworld",
  320. "owner": {
  321. "username": "laurynsentry",
  322. "display_name": "Lauryn Brown",
  323. "account_id": "5a00066393915e620920e0ae",
  324. "links": {
  325. "self": {"href": "https://api.bitbucket.org/2.0/users/laurynsentry"},
  326. "html": {"href": "https://bitbucket.org/laurynsentry/"},
  327. "avatar": {"href": "https://bitbucket.org/account/laurynsentry/avatar/"},
  328. },
  329. "type": "user",
  330. "uuid": "{e50a27fe-0686-4d75-ba44-d27608bbb718}",
  331. },
  332. "has_issues": True,
  333. "slug": "helloworld",
  334. "is_private": False,
  335. "size": 221349,
  336. "name": "HelloWorld",
  337. "language": "",
  338. "fork_policy": "allow_forks",
  339. "uuid": "{2a47ac11-098a-4054-8496-193754cae14b}",
  340. "mainbranch": {"type": "branch", "name": "master"},
  341. "updated_on": "2018-05-30T18:21:08.780363+00:00",
  342. "type": "repository",
  343. }