ghapi 2.0.2__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {ghapi-2.0.2/ghapi.egg-info → ghapi-2.0.3}/PKG-INFO +1 -1
  2. ghapi-2.0.3/ghapi/__init__.py +1 -0
  3. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/_modidx.py +1 -0
  4. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/core.py +18 -0
  5. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/skill.py +8 -0
  6. {ghapi-2.0.2 → ghapi-2.0.3/ghapi.egg-info}/PKG-INFO +1 -1
  7. ghapi-2.0.2/ghapi/__init__.py +0 -1
  8. {ghapi-2.0.2 → ghapi-2.0.3}/CONTRIBUTING.md +0 -0
  9. {ghapi-2.0.2 → ghapi-2.0.3}/LICENSE +0 -0
  10. {ghapi-2.0.2 → ghapi-2.0.3}/MANIFEST.in +0 -0
  11. {ghapi-2.0.2 → ghapi-2.0.3}/README.md +0 -0
  12. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/actions.py +0 -0
  13. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/all.py +0 -0
  14. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/auth.py +0 -0
  15. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/build_lib.py +0 -0
  16. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/cli.py +0 -0
  17. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/event.py +0 -0
  18. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/gh_spec.py +0 -0
  19. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/graphql.py +0 -0
  20. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/page.py +0 -0
  21. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/py.typed +0 -0
  22. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi/templates.py +0 -0
  23. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi.egg-info/SOURCES.txt +0 -0
  24. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi.egg-info/dependency_links.txt +0 -0
  25. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi.egg-info/entry_points.txt +0 -0
  26. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi.egg-info/requires.txt +0 -0
  27. {ghapi-2.0.2 → ghapi-2.0.3}/ghapi.egg-info/top_level.txt +0 -0
  28. {ghapi-2.0.2 → ghapi-2.0.3}/pyproject.toml +0 -0
  29. {ghapi-2.0.2 → ghapi-2.0.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ghapi
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: A python client for the GitHub API
5
5
  Author-email: Jeremy Howard <info@fast.ai>
6
6
  License: Apache-2.0
@@ -0,0 +1 @@
1
+ __version__ = "2.0.3"
@@ -49,6 +49,7 @@ d = { 'settings': { 'branch': 'main',
49
49
  'ghapi.core.GhApi._get_repo_files': ('core.html#ghapi._get_repo_files', 'ghapi/core.py'),
50
50
  'ghapi.core.GhApi._repr_markdown_': ('core.html#ghapi._repr_markdown_', 'ghapi/core.py'),
51
51
  'ghapi.core.GhApi.check_status': ('core.html#ghapi.check_status', 'ghapi/core.py'),
52
+ 'ghapi.core.GhApi.commit_tree': ('core.html#ghapi.commit_tree', 'ghapi/core.py'),
52
53
  'ghapi.core.GhApi.create_branch_empty': ('core.html#ghapi.create_branch_empty', 'ghapi/core.py'),
53
54
  'ghapi.core.GhApi.create_file': ('core.html#ghapi.create_file', 'ghapi/core.py'),
54
55
  'ghapi.core.GhApi.create_gist': ('core.html#ghapi.create_gist', 'ghapi/core.py'),
@@ -263,6 +263,24 @@ async def get_branch(self:GhApi, branch=None):
263
263
  branch = branch or (await self.repos.get()).default_branch
264
264
  return (await self.list_branches(branch))[0]
265
265
 
266
+ # %% ../nbs/00_core.ipynb #9f70ac44
267
+ @patch
268
+ async def commit_tree(self:GhApi, branch, message, tree, base=None):
269
+ "Commit `tree` entries to `branch`, creating it from `base` when needed"
270
+ try:
271
+ ref = await self.git.get_ref(f'heads/{branch}')
272
+ exists = True
273
+ except APIError as e:
274
+ if e.status_code != 404: raise
275
+ base = base or (await self.repos.get()).default_branch
276
+ ref,exists = await self.git.get_ref(f'heads/{base}'),False
277
+ parent = await self.git.get_commit(ref.object.sha)
278
+ new_tree = await self.git.create_tree(tree, parent.tree.sha)
279
+ commit = await self.git.create_commit(message, new_tree.sha, [parent.sha])
280
+ if exists: await self.git.update_ref(f'heads/{branch}', commit.sha)
281
+ else: await self.git.create_ref(f'refs/heads/{branch}', commit.sha)
282
+ return commit
283
+
266
284
  # %% ../nbs/00_core.ipynb #93b24881
267
285
  @patch
268
286
  async def list_files(self:GhApi, branch=None):
@@ -60,6 +60,14 @@ For anything that's about the local repo/working tree rather than GitHub itself
60
60
 
61
61
  `Git.__call__` prints (not raises) on a `CalledProcessError` unless you pass `mute_errors=True` -- check the return value, don't assume no exception means success.
62
62
 
63
+ # External PRs
64
+
65
+ For a PR to another owner's repo, use normal local Git through the commit, ensure your fork exists, then use one client scoped to the fork. `commit_tree` uploads GitHub tree entries as one commit without Git transport authentication; override `owner` only when creating the upstream PR:
66
+
67
+ api = GhApi('me', repo)
68
+ await api.commit_tree(branch, message, entries)
69
+ await api.pulls.create(owner='upstream', head=f'me:{branch}', base='main', title=title, body=body)
70
+
63
71
  # Gotchas
64
72
 
65
73
  - A PR *is* an issue for general comments (`issues.list_comments`, not `pulls.*`) -- inline code-review comments are the separate `pulls.list_review_comments`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ghapi
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: A python client for the GitHub API
5
5
  Author-email: Jeremy Howard <info@fast.ai>
6
6
  License: Apache-2.0
@@ -1 +0,0 @@
1
- __version__ = "2.0.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes