ticket2pr 0.3.0__py2.py3-none-any.whl → 0.3.1__py2.py3-none-any.whl

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.
src/branch_creator.py CHANGED
@@ -1,7 +1,12 @@
1
+ import logging
1
2
  import re
3
+ from datetime import datetime
2
4
 
3
5
  from src.clients.github_client import GitHubClient
4
6
  from src.clients.jira_client import JiraClient, JiraIssue
7
+ from src.exceptions import GithubBranchAlreadyExistsError
8
+
9
+ logger = logging.getLogger(__name__)
5
10
 
6
11
 
7
12
  def sanitize_branch_name(name: str, max_length: int = 100) -> str:
@@ -42,7 +47,20 @@ def create_branch_from_jira_issue(
42
47
  branch_name = generate_branch_name(jira_issue.key, jira_issue.summary, jira_issue.type)
43
48
  # TODO: Consider replacing the 2 next lines with local git client
44
49
  base_ref = github_client.get_base_branch_ref(base_branch)
45
- branch_url = github_client.create_branch(branch_name, base_ref)
50
+
51
+ try:
52
+ branch_url = github_client.create_branch(branch_name, base_ref)
53
+ except GithubBranchAlreadyExistsError:
54
+ # Branch already exists, add timestamp suffix and retry
55
+ original_branch_name = branch_name
56
+ timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
57
+ branch_name = f"{branch_name}-{timestamp}"
58
+ logger.info(
59
+ "Branch '%s' already exists. Retrying with new name: '%s'",
60
+ original_branch_name,
61
+ branch_name,
62
+ )
63
+ branch_url = github_client.create_branch(branch_name, base_ref)
46
64
 
47
65
  jira_client.link_branch(jira_issue.key, branch_url, branch_name)
48
66
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ticket2pr
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Automate Jira ticket to GitHub PR workflow
5
5
  Home-page: https://github.com/bengabay11/ticket2pr
6
6
  Author: Ben Gabay
@@ -1,5 +1,5 @@
1
1
  src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- src/branch_creator.py,sha256=W0kttV0WAp5xtpGpBk_oDHtLYYVeGYpZt_OF3S3GSfk,1580
2
+ src/branch_creator.py,sha256=8KqlIjP-VDnB8_qd_1NjiyimAs6yn5xJdr0o9OMtzsw,2230
3
3
  src/cli.py,sha256=zqKsJqcVortkcJ4VOkqQe6Xf5o_7U4kcIXSzUhU15PM,5811
4
4
  src/console_utils.py,sha256=TbVl_WhiGi1Kq7txk_WpCIfs7gvTJ3qPrSNVBOZ_ZiQ,6928
5
5
  src/enhanced_git.py,sha256=IcZb7e_7f8z6VyuAoy9q0J1TEF30B3vG-4WG5IrgbuQ,4245
@@ -28,9 +28,9 @@ tests/integration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
28
28
  tests/integration/test_find_first_toml.py,sha256=Wq4rDReqcWLC0CsgcDBDX62wtMljcsm8UHUDTLr4-_A,902
29
29
  tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  tests/unit/test_nothing.py,sha256=qRI0MSdLiBRklBNEsOAkr4jxfcrO2v2CuB2hHWePonU,103
31
- ticket2pr-0.3.0.dist-info/licenses/LICENSE,sha256=omgsokA67LJXOOKpXtf1wNH71Bfs35NWEAuLowNUMyM,1066
32
- ticket2pr-0.3.0.dist-info/METADATA,sha256=JlxjDaUv7kKwyZ5iu9cO8KBdJNsK6brh_hWtCbIF1vU,3264
33
- ticket2pr-0.3.0.dist-info/WHEEL,sha256=Mk1ST5gDzEO5il5kYREiBnzzM469m5sI8ESPl7TRhJY,110
34
- ticket2pr-0.3.0.dist-info/entry_points.txt,sha256=DnWUjexpwtqVcRSICrpnveMIjGJA9_0K5IjZt10jVkM,47
35
- ticket2pr-0.3.0.dist-info/top_level.txt,sha256=KW3xgkz9NLMTcmmzgKvW8RFpCFkRIQ085qzq2diFf68,10
36
- ticket2pr-0.3.0.dist-info/RECORD,,
31
+ ticket2pr-0.3.1.dist-info/licenses/LICENSE,sha256=omgsokA67LJXOOKpXtf1wNH71Bfs35NWEAuLowNUMyM,1066
32
+ ticket2pr-0.3.1.dist-info/METADATA,sha256=nrAa9Ytiq62HIsHzx8ueJax6R6dEK8jTw1f4z5tZZGA,3264
33
+ ticket2pr-0.3.1.dist-info/WHEEL,sha256=Mk1ST5gDzEO5il5kYREiBnzzM469m5sI8ESPl7TRhJY,110
34
+ ticket2pr-0.3.1.dist-info/entry_points.txt,sha256=DnWUjexpwtqVcRSICrpnveMIjGJA9_0K5IjZt10jVkM,47
35
+ ticket2pr-0.3.1.dist-info/top_level.txt,sha256=KW3xgkz9NLMTcmmzgKvW8RFpCFkRIQ085qzq2diFf68,10
36
+ ticket2pr-0.3.1.dist-info/RECORD,,