Skip to content

Commit 5e54700

Browse files
djachkovgonchik
authored andcommitted
Bitbucket: modify get_commits; Confluence: add example how to attach a file (#431)
* Bitbucket: add get_users; add example; add to documentation * Jira: add new Tempo method; update docs for new methods; add example * Add example for confluence * Bitbucket: modify get_commits function
1 parent a1da484 commit 5e54700

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

atlassian/bitbucket.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,24 +1081,43 @@ def get_diff(self, project, repository, path, hash_oldest, hash_newest):
10811081
params['to'] = hash_newest
10821082
return (self.get(url, params=params) or {}).get('diffs')
10831083

1084-
def get_commits(self, project, repository, hash_oldest, hash_newest, limit=99999):
1084+
def get_commits(self, project, repository, hash_oldest=None, hash_newest=None, follow_renames=False,
1085+
ignore_missing=False, merges="include", with_counts=False,
1086+
avatar_size=None, avatar_scheme=None, limit=99999):
10851087
"""
10861088
Get commit list from repo
10871089
:param project:
10881090
:param repository:
10891091
:param hash_oldest:
10901092
:param hash_newest:
1093+
:param merges: OPTIONAL: include|exclude|only if present, controls how merge commits should be filtered.
1094+
:param follow_renames: OPTIONAL: if true, the commit history of the specified file will be followed past renames.
1095+
:param ignore_missing: OPTIONAL: true to ignore missing commits, false otherwise
1096+
:param with_counts: OPTIONAL: optionally include the total number of commits and total number of unique authors
1097+
:param avatar_size: OPTIONAL: if present the service adds avatar URLs for commit authors.
1098+
:param avatar_scheme: OPTIONAL: the desired scheme for the avatar URL
10911099
:param limit: OPTIONAL: The limit of the number of commits to return, this may be restricted by
10921100
fixed system limits. Default by built-in method: 99999
10931101
:return:
10941102
"""
10951103
url = 'rest/api/1.0/projects/{project}/repos/{repository}/commits'.format(project=project,
10961104
repository=repository)
10971105
params = {}
1106+
params["merges"] = merges
10981107
if hash_oldest:
10991108
params['since'] = hash_oldest
11001109
if hash_newest:
11011110
params['until'] = hash_newest
1111+
if follow_renames:
1112+
params['followRenames'] = follow_renames
1113+
if ignore_missing:
1114+
params['ignoreMissing'] = ignore_missing
1115+
if with_counts:
1116+
params['withCounts'] = with_counts
1117+
if avatar_size:
1118+
params['avatarSize'] = avatar_size
1119+
if avatar_scheme:
1120+
params['avatarScheme'] = avatar_scheme
11021121
if limit:
11031122
params['limit'] = limit
11041123
return (self.get(url, params=params) or {}).get('values')
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# coding=utf-8
2+
from atlassian import Confluence
3+
from datetime import datetime
4+
import logging
5+
6+
7+
confluence = Confluence(
8+
url='http://localhost:8090',
9+
username='admin',
10+
password='admin',
11+
)
12+
13+
logging.basicConfig(level=logging.DEBUG)
14+
15+
filename = "test_file.txt"
16+
with open(filename, "w") as f:
17+
f.write(str(datetime.utcnow()))
18+
19+
confluence.attach_file(filename, page_id="123456789")
20+
21+
link = """<p>
22+
<ac:link>
23+
<ri:attachment ri:filename="{}"/>
24+
</ac:link>
25+
</p>""".format(filename)
26+
27+
confluence.append_page(123456789, "Page Title", link)

0 commit comments

Comments
 (0)