From 95202891cef5f0bd361ccbaa1f57c8f4de67e81e Mon Sep 17 00:00:00 2001 From: D0wn10ad <45912415+D0wn10ad@users.noreply.github.com> Date: Tue, 18 Feb 2025 06:22:41 +0800 Subject: [PATCH 1/6] Update README.md --- README.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8be0125..fa4fe05 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ A summary of the currently supported features: Grab a Phabricator token at `https:///settings/panel/apitokens/` -Configure: +Configure in Linux: ```bash export PHAB_TOKEN=cli-ABC123 @@ -44,10 +44,34 @@ export PHAB_TOKEN=cli-ABC123 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 From 282e05d49ea482aabab5eb4ba159c7bb0c97e3b6 Mon Sep 17 00:00:00 2001 From: D0wn10ad <45912415+D0wn10ad@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:14:21 +0800 Subject: [PATCH 2/6] Update maniphest.py added handling of over 100 projects/tags --- phabfive/maniphest.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/phabfive/maniphest.py b/phabfive/maniphest.py index 9dd9fb9..e6d063b 100644 --- a/phabfive/maniphest.py +++ b/phabfive/maniphest.py @@ -140,7 +140,12 @@ 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": ""}) + project_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"]) + project_query.extend(raw_data.data) + project_name_to_id_map = { project["fields"]["name"]: project["phid"] for project in projects_query["data"] @@ -383,4 +388,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') \ No newline at end of file + return dt.strftime('%Y-%m-%dT%H:%M:%S') From 04401a15624de921efd58c547a70a6cc24316bf9 Mon Sep 17 00:00:00 2001 From: D0wn10ad <45912415+D0wn10ad@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:23:59 +0800 Subject: [PATCH 3/6] Update maniphest.py --- phabfive/maniphest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/phabfive/maniphest.py b/phabfive/maniphest.py index e6d063b..1469b04 100644 --- a/phabfive/maniphest.py +++ b/phabfive/maniphest.py @@ -141,10 +141,14 @@ def create_from_config(self, config_file, dry_run=False): # Fetch all projects in phabricator, used to map ticket -> projects later project_query = raw_data = self.phab.project.search(constraints={"name": ""}) - + log.debug(raw_data) + log.debug(raw_data.cursor["after"]) + 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"]) - project_query.extend(raw_data.data) + project_query.data.extend(raw_data.data) + log.debug(raw_data) + log.debug(raw_data.cursor["after"]) project_name_to_id_map = { project["fields"]["name"]: project["phid"] From cf64034cdc745d85fabff1742139f17d9789e4d8 Mon Sep 17 00:00:00 2001 From: D0wn10ad <45912415+D0wn10ad@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:27:29 +0800 Subject: [PATCH 4/6] Update maniphest.py --- phabfive/maniphest.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/phabfive/maniphest.py b/phabfive/maniphest.py index 1469b04..e6aea8d 100644 --- a/phabfive/maniphest.py +++ b/phabfive/maniphest.py @@ -140,16 +140,13 @@ 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 - project_query = raw_data = self.phab.project.search(constraints={"name": ""}) - log.debug(raw_data) - log.debug(raw_data.cursor["after"]) + 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"]) - project_query.data.extend(raw_data.data) - log.debug(raw_data) - log.debug(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"] From 9d262cfe1e90dc32601c07e5e4c8f4ce5fd8a0d4 Mon Sep 17 00:00:00 2001 From: D0wn10ad <45912415+D0wn10ad@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:35:58 +0800 Subject: [PATCH 5/6] Update maniphest.py --- phabfive/maniphest.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/phabfive/maniphest.py b/phabfive/maniphest.py index e6aea8d..26bf868 100644 --- a/phabfive/maniphest.py +++ b/phabfive/maniphest.py @@ -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 + 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"] @@ -140,6 +148,8 @@ 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 + # 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 projects_query = raw_data = self.phab.project.search(constraints={"name": ""}) while (len(raw_data.data) >= 100 and not raw_data.cursor["after"] is None): From 260dcc3aa1c855fa90a9c7357ece107f05c61eea Mon Sep 17 00:00:00 2001 From: D0wn10ad <45912415+D0wn10ad@users.noreply.github.com> Date: Thu, 4 Dec 2025 17:48:13 +0800 Subject: [PATCH 6/6] Remove outdated comments on user and project fetching Removed comments regarding extended support for fetching users and projects from Phabricator. --- phabfive/maniphest.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/phabfive/maniphest.py b/phabfive/maniphest.py index def8a52..e923609 100644 --- a/phabfive/maniphest.py +++ b/phabfive/maniphest.py @@ -2144,8 +2144,6 @@ def create_from_config(self, config_file, dry_run=False): root_data = yaml_loader.load(stream) # Fetch all users in phabricator, used by subscribers mapping later - # 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 users_query = raw_data = self.phab.user.search() while (len(raw_data.data) >= 100 and not raw_data.cursor["after"] is None): @@ -2160,8 +2158,6 @@ 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 - # 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 projects_query = raw_data = self.phab.project.search(constraints={"name": ""}) while (len(raw_data.data) >= 100 and not raw_data.cursor["after"] is None):