jprint2 0.1.1__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.
- jprint2-0.1.1/.env.template +1 -0
- jprint2-0.1.1/.gitignore +20 -0
- jprint2-0.1.1/.pre-commit-config.yaml +36 -0
- jprint2-0.1.1/.python-version +1 -0
- jprint2-0.1.1/.secrets.baseline +127 -0
- jprint2-0.1.1/.secrets.baseline.update.sh +2 -0
- jprint2-0.1.1/LICENSE +21 -0
- jprint2-0.1.1/PKG-INFO +73 -0
- jprint2-0.1.1/README.md +46 -0
- jprint2-0.1.1/__init__.py +0 -0
- jprint2-0.1.1/dist/.gitignore +1 -0
- jprint2-0.1.1/donyfiles/.gitignore +7 -0
- jprint2-0.1.1/donyfiles/README.md +3 -0
- jprint2-0.1.1/donyfiles/__init__.py +0 -0
- jprint2-0.1.1/donyfiles/commands/__init__.py +0 -0
- jprint2-0.1.1/donyfiles/commands/release.py +93 -0
- jprint2-0.1.1/donyfiles/commands/squash.py +153 -0
- jprint2-0.1.1/donyfiles/pyproject.toml +11 -0
- jprint2-0.1.1/donyfiles/uv.lock +807 -0
- jprint2-0.1.1/jprint2/__init__.py +10 -0
- jprint2-0.1.1/jprint2/defaults.py +45 -0
- jprint2-0.1.1/jprint2/jformat.py +56 -0
- jprint2-0.1.1/jprint2/jprint.py +53 -0
- jprint2-0.1.1/pyproject.toml +43 -0
- jprint2-0.1.1/uv.lock +878 -0
@@ -0,0 +1 @@
|
|
1
|
+
UV_PUBLISH_TOKEN=
|
jprint2-0.1.1/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# - forbid all
|
2
|
+
|
3
|
+
**/*.*
|
4
|
+
|
5
|
+
# - allow subdirectories with a dot
|
6
|
+
!**/*.*/
|
7
|
+
!*.py
|
8
|
+
!.gitignore
|
9
|
+
!.python-version
|
10
|
+
!pyproject.toml
|
11
|
+
!uv.lock
|
12
|
+
!*.template
|
13
|
+
!.secrets.baseline
|
14
|
+
!*.sh
|
15
|
+
!*.yaml
|
16
|
+
!*.png
|
17
|
+
!*.md
|
18
|
+
|
19
|
+
# - forbid .venv
|
20
|
+
.venv
|
@@ -0,0 +1,36 @@
|
|
1
|
+
repos:
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3
|
+
rev: v4.6.0
|
4
|
+
hooks:
|
5
|
+
- id: check-added-large-files
|
6
|
+
args: ["--maxkb=1024"]
|
7
|
+
- id: check-merge-conflict
|
8
|
+
|
9
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
10
|
+
rev: v0.6.9
|
11
|
+
hooks:
|
12
|
+
# - Run the linter.
|
13
|
+
- id: ruff
|
14
|
+
types_or: [ python, pyi, jupyter ]
|
15
|
+
args: [
|
16
|
+
"--extend-exclude", "**/*_pb2.py",
|
17
|
+
"--fix",
|
18
|
+
"--config", "pyproject.toml",
|
19
|
+
"--ignore", "E722", # "Do not use bare 'except'"
|
20
|
+
"--ignore", "E731", # "Do not assign a lambda expression, use a def"
|
21
|
+
"--ignore", "F401" # "Module imported but unused"
|
22
|
+
]
|
23
|
+
# - Run the formatter.
|
24
|
+
- id: ruff-format
|
25
|
+
types_or: [ python, pyi, jupyter ]
|
26
|
+
args: [ "--config", "pyproject.toml" ]
|
27
|
+
|
28
|
+
- repo: https://github.com/Yelp/detect-secrets
|
29
|
+
rev: v1.5.0
|
30
|
+
hooks:
|
31
|
+
- id: detect-secrets
|
32
|
+
name: Detect secrets
|
33
|
+
language: python
|
34
|
+
entry: detect-secrets-hook
|
35
|
+
args: ["--baseline", ".secrets.baseline"]
|
36
|
+
exclude: '\.(json|csv|txt|ipynb)$'
|
@@ -0,0 +1 @@
|
|
1
|
+
3.8
|
@@ -0,0 +1,127 @@
|
|
1
|
+
{
|
2
|
+
"version": "1.5.0",
|
3
|
+
"plugins_used": [
|
4
|
+
{
|
5
|
+
"name": "ArtifactoryDetector"
|
6
|
+
},
|
7
|
+
{
|
8
|
+
"name": "AWSKeyDetector"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"name": "AzureStorageKeyDetector"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"name": "Base64HighEntropyString",
|
15
|
+
"limit": 4.5
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"name": "BasicAuthDetector"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "CloudantDetector"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "DiscordBotTokenDetector"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "GitHubTokenDetector"
|
28
|
+
},
|
29
|
+
{
|
30
|
+
"name": "GitLabTokenDetector"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"name": "HexHighEntropyString",
|
34
|
+
"limit": 3.0
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"name": "IbmCloudIamDetector"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "IbmCosHmacDetector"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"name": "IPPublicDetector"
|
44
|
+
},
|
45
|
+
{
|
46
|
+
"name": "JwtTokenDetector"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"name": "KeywordDetector",
|
50
|
+
"keyword_exclude": ""
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"name": "MailchimpDetector"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"name": "NpmDetector"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"name": "OpenAIDetector"
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"name": "PrivateKeyDetector"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"name": "PypiTokenDetector"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"name": "SendGridDetector"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"name": "SlackDetector"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"name": "SoftlayerDetector"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"name": "SquareOAuthDetector"
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"name": "StripeDetector"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "TelegramBotTokenDetector"
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"name": "TwilioKeyDetector"
|
87
|
+
}
|
88
|
+
],
|
89
|
+
"filters_used": [
|
90
|
+
{
|
91
|
+
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
|
95
|
+
"min_level": 2
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"path": "detect_secrets.filters.heuristic.is_lock_file"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
|
111
|
+
},
|
112
|
+
{
|
113
|
+
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"path": "detect_secrets.filters.heuristic.is_sequential_string"
|
117
|
+
},
|
118
|
+
{
|
119
|
+
"path": "detect_secrets.filters.heuristic.is_swagger_file"
|
120
|
+
},
|
121
|
+
{
|
122
|
+
"path": "detect_secrets.filters.heuristic.is_templated_secret"
|
123
|
+
}
|
124
|
+
],
|
125
|
+
"results": {},
|
126
|
+
"generated_at": "2025-05-09T11:02:56Z"
|
127
|
+
}
|
jprint2-0.1.1/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 marklidenberg
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
jprint2-0.1.1/PKG-INFO
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: jprint2
|
3
|
+
Version: 0.1.1
|
4
|
+
Summary: Simple json printer for python
|
5
|
+
Author-email: Mark Lidenberg <marklidenberg@gmail.com>
|
6
|
+
License: MIT
|
7
|
+
License-File: LICENSE
|
8
|
+
Classifier: Intended Audience :: Developers
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
17
|
+
Requires-Python: >=3.8
|
18
|
+
Requires-Dist: jsons>=1.6.3
|
19
|
+
Requires-Dist: pygments>=2.19.1
|
20
|
+
Provides-Extra: dev
|
21
|
+
Requires-Dist: better-exceptions>=0.3.3; extra == 'dev'
|
22
|
+
Requires-Dist: build>=1.2.2.post1; extra == 'dev'
|
23
|
+
Requires-Dist: load-dotenv>=0.1.0; extra == 'dev'
|
24
|
+
Requires-Dist: questionary>=2.1.0; extra == 'dev'
|
25
|
+
Requires-Dist: twine>=6.1.0; extra == 'dev'
|
26
|
+
Description-Content-Type: text/markdown
|
27
|
+
|
28
|
+
# jprint2
|
29
|
+
|
30
|
+
Print any object in JSON. Built on top of [jsons](https://github.com/ramonhagenaars/jsons) for formatting and [pygments](https://pygments.org/) for colorizing.
|
31
|
+
|
32
|
+
## Basic usage
|
33
|
+
|
34
|
+
```python
|
35
|
+
|
36
|
+
from jprint2 import jprint, jformat, set_defaults
|
37
|
+
|
38
|
+
# - Print json
|
39
|
+
|
40
|
+
jprint({"name": "Mark", "age": 30}) # {"name": "Mark", "age": 30}
|
41
|
+
|
42
|
+
# - Keeps strings by default as is to preserve json objects
|
43
|
+
|
44
|
+
jprint("Mark") # Mark
|
45
|
+
jprint('{"name": "Mark"}') # {"name": "Mark"}
|
46
|
+
jprint('{"name": "Mark"}', keep_strings=False) # "{\"name\": \"Mark\"}"
|
47
|
+
|
48
|
+
# - Set defaults of your liking
|
49
|
+
|
50
|
+
set_defaults(
|
51
|
+
indent=2,
|
52
|
+
sort_keys=True
|
53
|
+
)
|
54
|
+
|
55
|
+
# - Format json
|
56
|
+
|
57
|
+
my_json_string = jformat({"name": "Mark", "age": 30})
|
58
|
+
|
59
|
+
# - Override defaults
|
60
|
+
|
61
|
+
jprint({"name": "🧙♂️", "age": 30}, ensure_ascii=True) # {"name": "\ud83e\uddd9\u200d\u2642\ufe0f", "age": 30}
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+

|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
MIT License
|
70
|
+
|
71
|
+
## Author
|
72
|
+
|
73
|
+
Mark Lidenberg [marklidenberg@gmail.com](mailto:marklidenberg@gmail.com)
|
jprint2-0.1.1/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# jprint2
|
2
|
+
|
3
|
+
Print any object in JSON. Built on top of [jsons](https://github.com/ramonhagenaars/jsons) for formatting and [pygments](https://pygments.org/) for colorizing.
|
4
|
+
|
5
|
+
## Basic usage
|
6
|
+
|
7
|
+
```python
|
8
|
+
|
9
|
+
from jprint2 import jprint, jformat, set_defaults
|
10
|
+
|
11
|
+
# - Print json
|
12
|
+
|
13
|
+
jprint({"name": "Mark", "age": 30}) # {"name": "Mark", "age": 30}
|
14
|
+
|
15
|
+
# - Keeps strings by default as is to preserve json objects
|
16
|
+
|
17
|
+
jprint("Mark") # Mark
|
18
|
+
jprint('{"name": "Mark"}') # {"name": "Mark"}
|
19
|
+
jprint('{"name": "Mark"}', keep_strings=False) # "{\"name\": \"Mark\"}"
|
20
|
+
|
21
|
+
# - Set defaults of your liking
|
22
|
+
|
23
|
+
set_defaults(
|
24
|
+
indent=2,
|
25
|
+
sort_keys=True
|
26
|
+
)
|
27
|
+
|
28
|
+
# - Format json
|
29
|
+
|
30
|
+
my_json_string = jformat({"name": "Mark", "age": 30})
|
31
|
+
|
32
|
+
# - Override defaults
|
33
|
+
|
34
|
+
jprint({"name": "🧙♂️", "age": 30}, ensure_ascii=True) # {"name": "\ud83e\uddd9\u200d\u2642\ufe0f", "age": 30}
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+

|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
MIT License
|
43
|
+
|
44
|
+
## Author
|
45
|
+
|
46
|
+
Mark Lidenberg [marklidenberg@gmail.com](mailto:marklidenberg@gmail.com)
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
*
|
File without changes
|
File without changes
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import os
|
2
|
+
|
3
|
+
import dony
|
4
|
+
|
5
|
+
|
6
|
+
@dony.command()
|
7
|
+
def release(
|
8
|
+
version: str = None,
|
9
|
+
uv_publish_token: str = None,
|
10
|
+
):
|
11
|
+
"""Bump version and publish to PyPI"""
|
12
|
+
|
13
|
+
# - Select default arguments
|
14
|
+
|
15
|
+
version = version or dony.select(
|
16
|
+
"Choose version",
|
17
|
+
choices=[
|
18
|
+
"patch",
|
19
|
+
"minor",
|
20
|
+
"major",
|
21
|
+
],
|
22
|
+
)
|
23
|
+
|
24
|
+
uv_publish_token = uv_publish_token or dony.input(
|
25
|
+
"Enter UV publish token (usually a PyPI token)",
|
26
|
+
default=os.getenv("UV_PUBLISH_TOKEN", ""),
|
27
|
+
)
|
28
|
+
|
29
|
+
# - Get current branch
|
30
|
+
|
31
|
+
original_branch = dony.shell(
|
32
|
+
"git branch --show-current",
|
33
|
+
quiet=True,
|
34
|
+
)
|
35
|
+
|
36
|
+
# - Go to main
|
37
|
+
|
38
|
+
dony.shell("""
|
39
|
+
|
40
|
+
# - Exit if there are staged changes
|
41
|
+
|
42
|
+
git diff --cached --name-only | grep -q . && git stash
|
43
|
+
|
44
|
+
# - Go to main
|
45
|
+
|
46
|
+
git checkout main
|
47
|
+
|
48
|
+
# - Git pull
|
49
|
+
|
50
|
+
git pull
|
51
|
+
""")
|
52
|
+
|
53
|
+
# - Bump
|
54
|
+
|
55
|
+
dony.shell(
|
56
|
+
f"""
|
57
|
+
|
58
|
+
# - Bump
|
59
|
+
|
60
|
+
VERSION=$(uv version --bump {version} --short)
|
61
|
+
echo $VERSION
|
62
|
+
|
63
|
+
# - Commit, tag and push
|
64
|
+
|
65
|
+
git add pyproject.toml
|
66
|
+
git commit --message "chore: release-$VERSION"
|
67
|
+
git tag --annotate "release-$VERSION" --message "chore: release-$VERSION" HEAD
|
68
|
+
git push
|
69
|
+
git push origin "release-$VERSION" # push tag to origin,
|
70
|
+
"""
|
71
|
+
)
|
72
|
+
|
73
|
+
# - Build and publish
|
74
|
+
|
75
|
+
dony.shell(
|
76
|
+
f"""
|
77
|
+
uv build
|
78
|
+
UV_PUBLISH_TOKEN={uv_publish_token} uv publish
|
79
|
+
"""
|
80
|
+
)
|
81
|
+
|
82
|
+
# - Go back to original branch
|
83
|
+
|
84
|
+
dony.shell(
|
85
|
+
f"""
|
86
|
+
git checkout {original_branch}
|
87
|
+
git merge --no-edit {original_branch} && git push
|
88
|
+
"""
|
89
|
+
)
|
90
|
+
|
91
|
+
|
92
|
+
if __name__ == "__main__":
|
93
|
+
release()
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import re
|
2
|
+
|
3
|
+
import dony
|
4
|
+
|
5
|
+
|
6
|
+
__NAME__ = "squash:0.1.4"
|
7
|
+
|
8
|
+
|
9
|
+
@dony.command()
|
10
|
+
def squash(
|
11
|
+
new_branch: str = None,
|
12
|
+
target_branch: str = None,
|
13
|
+
commit_message: str = None,
|
14
|
+
checkout_to_new_branch: str = None,
|
15
|
+
remove_merged_branch: str = None,
|
16
|
+
):
|
17
|
+
"""Squashes current branch to main, checkouts to a new branch"""
|
18
|
+
|
19
|
+
# - Get default branch if not set
|
20
|
+
|
21
|
+
new_branch = (
|
22
|
+
new_branch or f"workflow_{dony.shell('date +%Y%m%d_%H%M%S', quiet=True)}"
|
23
|
+
)
|
24
|
+
|
25
|
+
# - Get current branch
|
26
|
+
|
27
|
+
merged_branch = dony.shell(
|
28
|
+
"git branch --show-current",
|
29
|
+
quiet=True,
|
30
|
+
)
|
31
|
+
|
32
|
+
# - Look for main/master branch
|
33
|
+
|
34
|
+
main_or_master_branch = dony.shell(
|
35
|
+
"git branch --list main | grep -q main && echo main || echo master",
|
36
|
+
quiet=True,
|
37
|
+
)
|
38
|
+
|
39
|
+
# - Get target branch
|
40
|
+
|
41
|
+
target_branch = target_branch or dony.input(
|
42
|
+
"Enter target branch:",
|
43
|
+
default=main_or_master_branch,
|
44
|
+
)
|
45
|
+
|
46
|
+
# - Do git diff
|
47
|
+
|
48
|
+
dony.shell(
|
49
|
+
f"""
|
50
|
+
root=$(git rev-parse --show-toplevel)
|
51
|
+
|
52
|
+
git diff {target_branch} --name-only -z \
|
53
|
+
| while IFS= read -r -d '' file; do
|
54
|
+
full="$root/$file"
|
55
|
+
printf '\033[1;35m%s\033[0m\n' "$full"
|
56
|
+
git --no-pager diff --color=always {target_branch} -- "$file" \
|
57
|
+
| sed $'s/^/\t/'
|
58
|
+
printf '\n'
|
59
|
+
done
|
60
|
+
"""
|
61
|
+
)
|
62
|
+
|
63
|
+
# Ask user to confirm
|
64
|
+
|
65
|
+
dony.confirm("Start squashing?", default=False)
|
66
|
+
|
67
|
+
# - Check if target branch exists
|
68
|
+
|
69
|
+
if (
|
70
|
+
dony.shell(
|
71
|
+
f"""
|
72
|
+
git branch --list {target_branch}
|
73
|
+
"""
|
74
|
+
)
|
75
|
+
== ""
|
76
|
+
):
|
77
|
+
return dony.error(f"Target branch {target_branch} does not exist")
|
78
|
+
|
79
|
+
# - Get commit message from the user
|
80
|
+
|
81
|
+
if not commit_message:
|
82
|
+
while True:
|
83
|
+
commit_message = dony.input(
|
84
|
+
f"Enter commit message for merging branch {merged_branch} to {target_branch}:"
|
85
|
+
)
|
86
|
+
if bool(
|
87
|
+
re.match(
|
88
|
+
r"^(?:(?:feat|fix|docs|style|refactor|perf|test|chore|build|ci|revert)(?:\([A-Za-z0-9_-]+\))?(!)?:)\s.+$",
|
89
|
+
commit_message.splitlines()[0],
|
90
|
+
)
|
91
|
+
):
|
92
|
+
break
|
93
|
+
dony.print("Only conventional commits are allowed, try again")
|
94
|
+
|
95
|
+
# - Check if user wants to checkout to a new branch
|
96
|
+
|
97
|
+
checkout_to_new_branch = dony.confirm(
|
98
|
+
f"Checkout to new branch {new_branch}?",
|
99
|
+
provided_answer=checkout_to_new_branch,
|
100
|
+
)
|
101
|
+
|
102
|
+
# - Check if user wants to remove merged branch
|
103
|
+
|
104
|
+
remove_merged_branch = dony.confirm(
|
105
|
+
f"Remove merged branch {merged_branch}?",
|
106
|
+
provided_answer=remove_merged_branch,
|
107
|
+
)
|
108
|
+
|
109
|
+
# - Do the process
|
110
|
+
|
111
|
+
dony.shell(
|
112
|
+
f"""
|
113
|
+
|
114
|
+
# - Make up to date
|
115
|
+
|
116
|
+
git diff --name-only | grep -q . && git stash push -m "squash-{merged_branch}"
|
117
|
+
git checkout {target_branch}
|
118
|
+
|
119
|
+
# - Set upstream if needed
|
120
|
+
|
121
|
+
if ! git ls-remote --heads --exit-code origin "{target_branch}" >/dev/null; then
|
122
|
+
git push --set-upstream origin {target_branch} --force
|
123
|
+
fi
|
124
|
+
|
125
|
+
# - Pull target branch
|
126
|
+
|
127
|
+
git pull
|
128
|
+
|
129
|
+
# - Merge
|
130
|
+
|
131
|
+
git merge --squash {merged_branch}
|
132
|
+
git commit -m "{commit_message}"
|
133
|
+
git push
|
134
|
+
|
135
|
+
# - Remove merged branch
|
136
|
+
|
137
|
+
if {str(remove_merged_branch).lower()}; then
|
138
|
+
git branch -D {merged_branch}
|
139
|
+
git push origin --delete {merged_branch}
|
140
|
+
fi
|
141
|
+
|
142
|
+
# - Create new branch
|
143
|
+
|
144
|
+
if {str(checkout_to_new_branch).lower()}; then
|
145
|
+
git checkout -b {new_branch}
|
146
|
+
git push --set-upstream origin {new_branch}
|
147
|
+
fi
|
148
|
+
""",
|
149
|
+
)
|
150
|
+
|
151
|
+
|
152
|
+
if __name__ == "__main__":
|
153
|
+
squash()
|