Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,42 @@ A summary of the currently supported features:

Grab a Phabricator token at `https://<yourserver.com>/settings/panel/apitokens/`

Configure:
Configure in Linux:

```bash
export PHAB_TOKEN=cli-ABC123
# --OR--
echo "PHAB_TOKEN: cli-ABC123" > ~/.config/phabfive.yaml
```

Configure in Windows:

Phabfive looks for configuration in the following sequence in Windows environment:

```Commnad prompt
%ALLUSERSPROFILE%\phabfive\phabfive.yaml
%ALLUSERSPROFILE%\phabfive\phabfive.d\*.yaml
%LOCALAPPDATA%\phabfive\phabfive.yaml
%LOCALAPPDATA%\phabfive\phabfive.d\*.yaml
```

Make sure there is a minimum phabfive.yaml store in one of the location
e.g.
```Commnad prompt
echo "PHAB_TOKEN: cli-ABC123" > %LOCALAPPDATA%\phabfive\phabfive.yaml
```

Additionally, due to connection to Phabricator server on HTTPS requires certificate verification, it is also recommended to install [pip_system_certs](https://pypi.org/project/pip-system-certs/) to ensure system store are linked to python.

```Commnad prompt
pip install pip_system_certs
```

Usage:

```bash
phabfive passphrase K123
phabfive --log-level=DEBUG user whoami
```

## Run local development phabricator instance
Expand Down
22 changes: 19 additions & 3 deletions phabfive/maniphest.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,15 @@ def create_from_config(self, config_file, dry_run=False):
root_data = yaml.load(stream, Loader=yaml.Loader) # nosec-B506

# Fetch all users in phabricator, used by subscribers mapping later
users_query = self.phab.user.search()
# Extended support for phabricator instances with more than 100 (i.e. deftault query limit) users
# BUT with limieted exception handling e.g. retries needed when phabricator instance is not responding to API calls
Copy link
Contributor

Choose a reason for hiding this comment

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

These comments could be removed. They only serve a purpose for the reviewer of this PR

users_query = raw_data = self.phab.user.search()

while (len(raw_data.data) >= 100 and not raw_data.cursor["after"] is None):
raw_data = self.phab.user.search(after=raw_data.cursor["after"])
users_query.data.extend(raw_data.data)
log.debug(users_query)

username_to_id_mapping = {
user["fields"]["username"]: user["phid"]
for user in users_query["data"]
Expand All @@ -140,7 +148,15 @@ def create_from_config(self, config_file, dry_run=False):
log.debug(username_to_id_mapping)

# Fetch all projects in phabricator, used to map ticket -> projects later
projects_query = self.phab.project.search(constraints={"name": ""})
# Extended support for phabricator instances with more than 100 (i.e. deftault query limit) projects
# BUT with limieted exception handling, e.g. retries needed when phabricator instance is not responding to API calls
Copy link
Contributor

Choose a reason for hiding this comment

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

These comments could be removed. They only serve a purpose for the reviewer of this PR

projects_query = raw_data = self.phab.project.search(constraints={"name": ""})

while (len(raw_data.data) >= 100 and not raw_data.cursor["after"] is None):
raw_data = self.phab.project.search(constraints={"name": ""},after=raw_data.cursor["after"])
projects_query.data.extend(raw_data.data)
log.debug(projects_query)

project_name_to_id_map = {
project["fields"]["name"]: project["phid"]
for project in projects_query["data"]
Expand Down Expand Up @@ -383,4 +399,4 @@ def format_timestamp(timestamp):
Convert UNIX timestamp to ISO 8601 string (readable time format).
"""
dt = datetime.datetime.fromtimestamp(timestamp)
return dt.strftime('%Y-%m-%dT%H:%M:%S')
return dt.strftime('%Y-%m-%dT%H:%M:%S')