git-commitflow 1.0.9__tar.gz → 1.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.
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/PKG-INFO +7 -5
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/README.md +4 -3
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow/__init__.py +25 -14
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow/git_commitflow.py +53 -53
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow.egg-info/PKG-INFO +7 -5
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/setup.py +1 -1
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/LICENSE +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow/cache_file.py +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow/helpers.py +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow/readline_manager.py +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow.egg-info/SOURCES.txt +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow.egg-info/dependency_links.txt +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow.egg-info/entry_points.txt +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow.egg-info/requires.txt +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/git_commitflow.egg-info/top_level.txt +0 -0
- {git_commitflow-1.0.9 → git_commitflow-1.1.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: git-commitflow
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: A git add/commit/push helper
|
|
5
5
|
Home-page: https://github.com/jamescherti/git-commitflow
|
|
6
6
|
Author: James Cherti
|
|
@@ -27,6 +27,7 @@ Dynamic: classifier
|
|
|
27
27
|
Dynamic: description
|
|
28
28
|
Dynamic: description-content-type
|
|
29
29
|
Dynamic: home-page
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
Dynamic: requires-dist
|
|
31
32
|
Dynamic: requires-python
|
|
32
33
|
Dynamic: summary
|
|
@@ -39,9 +40,10 @@ Dynamic: summary
|
|
|
39
40
|
The `git-commitflow` tool is an interactive command-line interface that assists with the Git operations.
|
|
40
41
|
|
|
41
42
|
Running `git-commitflow` guides the user through the following interactive steps:
|
|
42
|
-
- Prompting the user to add files (`git add`)
|
|
43
|
-
- Displaying differences to ensure accuracy and prevent mistakes before committing (`git diff`)
|
|
44
|
-
- Prompting the user to enter a commit message and then committing the changes (`git commit`)
|
|
43
|
+
- Prompting the user to add files (`git add`).
|
|
44
|
+
- Displaying differences to ensure accuracy and prevent mistakes before committing (`git diff`).
|
|
45
|
+
- Prompting the user to enter a commit message and then committing the changes (`git commit`).
|
|
46
|
+
- It first attempts to merge using `--ff-only`; if the merge fails, it prompts the user to confirm whether to proceed with a rebase using `--rebase` and `--autostash`. Afterward, it commits the changes.
|
|
45
47
|
- Optional (`-p` flag): Pushing updates to the remote repository (`git push`). The references are only pushed when they have never been pushed before. The `git-commitflow` tool maintains a list of references that have been pushed, preventing multiple pushes of the same reference. This reduces unnecessary pushes.
|
|
46
48
|
|
|
47
49
|
One significant benefit of the `git-commitflow` tool is that it enhances the user's awareness and control over their changes before committing. This reduces the likelihood of including unintended files or alterations in commits, promoting a cleaner and more organized version history.
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
The `git-commitflow` tool is an interactive command-line interface that assists with the Git operations.
|
|
7
7
|
|
|
8
8
|
Running `git-commitflow` guides the user through the following interactive steps:
|
|
9
|
-
- Prompting the user to add files (`git add`)
|
|
10
|
-
- Displaying differences to ensure accuracy and prevent mistakes before committing (`git diff`)
|
|
11
|
-
- Prompting the user to enter a commit message and then committing the changes (`git commit`)
|
|
9
|
+
- Prompting the user to add files (`git add`).
|
|
10
|
+
- Displaying differences to ensure accuracy and prevent mistakes before committing (`git diff`).
|
|
11
|
+
- Prompting the user to enter a commit message and then committing the changes (`git commit`).
|
|
12
|
+
- It first attempts to merge using `--ff-only`; if the merge fails, it prompts the user to confirm whether to proceed with a rebase using `--rebase` and `--autostash`. Afterward, it commits the changes.
|
|
12
13
|
- Optional (`-p` flag): Pushing updates to the remote repository (`git push`). The references are only pushed when they have never been pushed before. The `git-commitflow` tool maintains a list of references that have been pushed, preventing multiple pushes of the same reference. This reduces unnecessary pushes.
|
|
13
14
|
|
|
14
15
|
One significant benefit of the `git-commitflow` tool is that it enhances the user's awareness and control over their changes before committing. This reduces the likelihood of including unintended files or alterations in commits, promoting a cleaner and more organized version history.
|
|
@@ -29,28 +29,29 @@ import colorama
|
|
|
29
29
|
from .git_commitflow import GitCommitFlow
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def
|
|
33
|
-
"""
|
|
34
|
-
logging.basicConfig(level=logging.INFO, stream=sys.stdout,
|
|
35
|
-
format="%(asctime)s %(name)s: %(message)s")
|
|
36
|
-
colorama.init()
|
|
32
|
+
def flush_stdin():
|
|
33
|
+
"""Clear any pending input from the standard input buffer.
|
|
37
34
|
|
|
35
|
+
This function ensures that no stale or unintended data remains in stdin
|
|
36
|
+
before reading user input interactively. On Windows, it uses the msvcrt
|
|
37
|
+
module to discard characters from the input buffer. On POSIX-compliant
|
|
38
|
+
systems (e.g., Linux, macOS...), it uses select to check for available
|
|
39
|
+
input without blocking and either discards the data by reading or flushes
|
|
40
|
+
it using termios.tcflush if stdin is a terminal.
|
|
41
|
+
"""
|
|
38
42
|
try:
|
|
39
|
-
import platform # pylint: disable=import-outside-toplevel
|
|
40
43
|
if os.name == "nt":
|
|
41
44
|
import msvcrt # pylint: disable=import-outside-toplevel
|
|
42
45
|
|
|
43
|
-
# Check if there
|
|
46
|
+
# For Windows systems, Check if there is any pending input in the
|
|
47
|
+
# buffer Discard characters one at a time until the buffer is empty
|
|
44
48
|
while msvcrt.kbhit():
|
|
45
|
-
# Read and discard one character at a time
|
|
46
49
|
msvcrt.getch()
|
|
47
|
-
elif os.name == "posix"
|
|
48
|
-
# For Unix-like systems, check if there's any pending input in
|
|
49
|
-
# stdin without blocking
|
|
50
|
+
elif os.name == "posix":
|
|
50
51
|
import select # pylint: disable=import-outside-toplevel
|
|
51
52
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
53
|
+
# For Unix-like systems, check if there's any pending input in
|
|
54
|
+
# stdin without blocking
|
|
54
55
|
stdin, _, _ = select.select([sys.stdin], [], [], 0)
|
|
55
56
|
if stdin:
|
|
56
57
|
if sys.stdin.isatty():
|
|
@@ -61,10 +62,20 @@ def git_commitflow_cli():
|
|
|
61
62
|
tcflush(sys.stdin.fileno(), TCIFLUSH)
|
|
62
63
|
else:
|
|
63
64
|
# Read and discard input (in chunks)
|
|
64
|
-
sys.stdin.read(1024)
|
|
65
|
+
while sys.stdin.read(1024):
|
|
66
|
+
pass
|
|
65
67
|
except ImportError:
|
|
66
68
|
pass
|
|
67
69
|
|
|
70
|
+
|
|
71
|
+
def git_commitflow_cli():
|
|
72
|
+
"""The git-commitflow command-line interface."""
|
|
73
|
+
logging.basicConfig(level=logging.INFO, stream=sys.stdout,
|
|
74
|
+
format="%(asctime)s %(name)s: %(message)s")
|
|
75
|
+
colorama.init()
|
|
76
|
+
|
|
77
|
+
flush_stdin()
|
|
78
|
+
|
|
68
79
|
try:
|
|
69
80
|
GitCommitFlow().main()
|
|
70
81
|
except subprocess.CalledProcessError as main_proc_err:
|
|
@@ -42,41 +42,38 @@ GIT_DIFF_OPTS: List[str] = []
|
|
|
42
42
|
MIN_COMMIT_MESSAGE_SIZE = 1
|
|
43
43
|
GIT_COMMITFLOW_DATA_DIR = Path("~/.config/git-commitflow").expanduser()
|
|
44
44
|
CACHE_FILE = GIT_COMMITFLOW_DATA_DIR / "repo-data.json"
|
|
45
|
-
IGNORE_FILENAMES_REGEX:
|
|
45
|
+
IGNORE_FILENAMES_REGEX: list = []
|
|
46
46
|
HISTORY_LENGTH = 256
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
class GitCommitFlow:
|
|
50
50
|
def __init__(self):
|
|
51
|
-
GIT_COMMITFLOW_DATA_DIR.mkdir(parents=True, exist_ok=True)
|
|
52
|
-
|
|
53
51
|
self.args = self._parse_args()
|
|
52
|
+
GIT_COMMITFLOW_DATA_DIR.mkdir(parents=True, exist_ok=True)
|
|
54
53
|
|
|
55
|
-
self.git_repo_dir =
|
|
56
|
-
|
|
57
|
-
self.git_repo_dir = None
|
|
58
|
-
self.find_git_repo_dir() # Update self.git_repo_dir
|
|
59
|
-
|
|
60
|
-
self.amount_commits = self.count_commits()
|
|
61
|
-
self.cache = CacheFile(CACHE_FILE)
|
|
62
|
-
|
|
54
|
+
self.git_repo_dir = self._find_git_repo_dir()
|
|
63
55
|
self.branch = self._get_first_line_cmd("git symbolic-ref --short HEAD")
|
|
56
|
+
self.amount_commits = self._count_commits()
|
|
57
|
+
self.readline_manager = self._init_prompt_and_history()
|
|
58
|
+
self.cache = CacheFile(CACHE_FILE)
|
|
64
59
|
|
|
60
|
+
def _init_prompt_and_history(self):
|
|
65
61
|
# History
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
git_common_dir = \
|
|
62
|
+
prompt_history_file = None
|
|
63
|
+
dot_git_dir = \
|
|
69
64
|
self._get_first_line_cmd("git rev-parse --git-common-dir").strip()
|
|
70
|
-
if
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
if not dot_git_dir:
|
|
66
|
+
print("Error: The .git directory could not be located",
|
|
67
|
+
file=sys.stderr)
|
|
68
|
+
sys.exit(1)
|
|
69
|
+
|
|
70
|
+
prompt_history_file = \
|
|
71
|
+
Path(dot_git_dir).joinpath("git-commitflow-history.rl")
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
ReadlineManager(history_file=self.prompt_history_file,
|
|
79
|
-
history_length=HISTORY_LENGTH)
|
|
73
|
+
logging.debug("[DEBUG] History file: %s", str(prompt_history_file))
|
|
74
|
+
|
|
75
|
+
return ReadlineManager(history_file=prompt_history_file,
|
|
76
|
+
history_length=HISTORY_LENGTH)
|
|
80
77
|
|
|
81
78
|
def _parse_args(self):
|
|
82
79
|
"""Parse command-line arguments."""
|
|
@@ -89,7 +86,11 @@ class GitCommitFlow:
|
|
|
89
86
|
default=False,
|
|
90
87
|
action="store_true",
|
|
91
88
|
required=False,
|
|
92
|
-
help="Git push after a successful commit"
|
|
89
|
+
help=("Git push after a successful commit. (The references are "
|
|
90
|
+
"pushed only if they have not been pushed previously. The "
|
|
91
|
+
"git-commitflow tool keeps track of the references that "
|
|
92
|
+
"have been pushed, preventing the same reference from being "
|
|
93
|
+
"pushed multiple times. This minimizes redundant pushes.)"),
|
|
93
94
|
)
|
|
94
95
|
|
|
95
96
|
parser.add_argument(
|
|
@@ -185,10 +186,6 @@ class GitCommitFlow:
|
|
|
185
186
|
try:
|
|
186
187
|
subprocess.check_call(["git", "commit"] + git_commit_opts)
|
|
187
188
|
|
|
188
|
-
# TODO: maybe git show without a pager?
|
|
189
|
-
# print()
|
|
190
|
-
# subprocess.check_call(["git", "show"])
|
|
191
|
-
|
|
192
189
|
print()
|
|
193
190
|
print(Fore.GREEN + "[COMMIT] git commit was SUCCESSFUL." +
|
|
194
191
|
Fore.RESET)
|
|
@@ -207,7 +204,10 @@ class GitCommitFlow:
|
|
|
207
204
|
# Load cache
|
|
208
205
|
# --------------
|
|
209
206
|
remote_url = self._get_first_line_cmd("git ls-remote --get-url")
|
|
210
|
-
|
|
207
|
+
|
|
208
|
+
# ------------------------
|
|
209
|
+
# Init commit refs (cache)
|
|
210
|
+
# ------------------------
|
|
211
211
|
git_push_commit_refs = self.cache.get("git_push_commit_refs", {})
|
|
212
212
|
|
|
213
213
|
try:
|
|
@@ -216,14 +216,14 @@ class GitCommitFlow:
|
|
|
216
216
|
git_push_commit_refs[remote_url] = {}
|
|
217
217
|
|
|
218
218
|
try:
|
|
219
|
-
git_push_commit_refs[remote_url][branch]
|
|
219
|
+
git_push_commit_refs[remote_url][self.branch]
|
|
220
220
|
except KeyError:
|
|
221
|
-
git_push_commit_refs[remote_url][branch] = ""
|
|
221
|
+
git_push_commit_refs[remote_url][self.branch] = ""
|
|
222
222
|
|
|
223
223
|
commit_ref = \
|
|
224
224
|
self._get_first_line_cmd("git rev-parse --verify HEAD")
|
|
225
225
|
|
|
226
|
-
if commit_ref == git_push_commit_refs[remote_url][branch]:
|
|
226
|
+
if commit_ref == git_push_commit_refs[remote_url][self.branch]:
|
|
227
227
|
print(f"[PUSH] Already pushed: " f"{self.git_repo_dir}")
|
|
228
228
|
return True
|
|
229
229
|
|
|
@@ -236,10 +236,12 @@ class GitCommitFlow:
|
|
|
236
236
|
return True # No git remote
|
|
237
237
|
|
|
238
238
|
try:
|
|
239
|
-
#
|
|
239
|
+
# Display the remote branch that is tracked by the current local
|
|
240
240
|
# branch The error message will be: fatal: no such branch: 'master'
|
|
241
241
|
subprocess.check_call(["git", "rev-parse",
|
|
242
|
-
"--symbolic-full-name", "HEAD@{u}"]
|
|
242
|
+
"--symbolic-full-name", "HEAD@{u}"],
|
|
243
|
+
stdout=subprocess.DEVNULL,
|
|
244
|
+
stderr=subprocess.DEVNULL)
|
|
243
245
|
|
|
244
246
|
subprocess.check_call(["git", "fetch", "-a"])
|
|
245
247
|
except subprocess.CalledProcessError as proc_err:
|
|
@@ -273,10 +275,9 @@ class GitCommitFlow:
|
|
|
273
275
|
# Update cache file
|
|
274
276
|
# ------------------
|
|
275
277
|
if success:
|
|
276
|
-
branch = self._get_first_line_cmd("git symbolic-ref --short HEAD")
|
|
277
278
|
commit_ref = \
|
|
278
279
|
self._get_first_line_cmd("git rev-parse --verify HEAD")
|
|
279
|
-
git_push_commit_refs[remote_url][branch] = commit_ref
|
|
280
|
+
git_push_commit_refs[remote_url][self.branch] = commit_ref
|
|
280
281
|
self.cache.set("git_push_commit_refs", git_push_commit_refs)
|
|
281
282
|
|
|
282
283
|
return success
|
|
@@ -287,9 +288,9 @@ class GitCommitFlow:
|
|
|
287
288
|
except subprocess.CalledProcessError:
|
|
288
289
|
return default_value
|
|
289
290
|
|
|
290
|
-
def
|
|
291
|
+
def _find_git_repo_dir(self):
|
|
291
292
|
try:
|
|
292
|
-
|
|
293
|
+
return Path(
|
|
293
294
|
self._get_first_line_cmd("git rev-parse --show-toplevel",
|
|
294
295
|
check=True)
|
|
295
296
|
)
|
|
@@ -302,7 +303,7 @@ class GitCommitFlow:
|
|
|
302
303
|
"is not a directory", file=sys.stderr)
|
|
303
304
|
sys.exit(1)
|
|
304
305
|
|
|
305
|
-
def
|
|
306
|
+
def _count_commits(self):
|
|
306
307
|
return len(self._run("git rev-list --all --count"))
|
|
307
308
|
|
|
308
309
|
def _get_first_line_cmd(self, cmd, **kwargs) -> str:
|
|
@@ -371,25 +372,24 @@ class GitCommitFlow:
|
|
|
371
372
|
|
|
372
373
|
print(f"Author: {Fore.YELLOW + git_author + Fore.RESET} ")
|
|
373
374
|
print("Branch:", Fore.YELLOW + self.branch + Fore.RESET)
|
|
374
|
-
print("Git message: ", end="")
|
|
375
|
+
# print("Git message: ", end="")
|
|
375
376
|
|
|
376
|
-
commit_message = self.git_config_get("custom.commit-message").strip()
|
|
377
|
-
previous_message = ""
|
|
378
|
-
if commit_message:
|
|
379
|
-
|
|
380
|
-
elif self.amount_commits > 0:
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
377
|
+
# commit_message = self.git_config_get("custom.commit-message").strip()
|
|
378
|
+
# previous_message = ""
|
|
379
|
+
# if commit_message:
|
|
380
|
+
# print(Fore.YELLOW + commit_message + Fore.RESET)
|
|
381
|
+
# elif self.amount_commits > 0:
|
|
382
|
+
# previous_message = \
|
|
383
|
+
# "\n".join(
|
|
384
|
+
# self._run("git --no-pager log -1 --pretty=%B")).rstrip()
|
|
385
|
+
# print(Fore.YELLOW + previous_message + Fore.RESET)
|
|
385
386
|
|
|
386
|
-
commit_message = self.prompt_git_commit_message(commit_message)
|
|
387
|
+
# commit_message = self.prompt_git_commit_message(commit_message)
|
|
388
|
+
commit_message = self.prompt_git_commit_message("")
|
|
387
389
|
|
|
388
390
|
# TODO: move this to a function
|
|
389
|
-
logging.debug("[DEBUG] Previous message: %s", previous_message)
|
|
391
|
+
# logging.debug("[DEBUG] Previous message: %s", previous_message)
|
|
390
392
|
logging.debug("[DEBUG] Commit message: %s", commit_message)
|
|
391
|
-
# if self.prompt_history_file and not commit_message and previous_message:
|
|
392
|
-
# self.readline_manager.append_to_history(previous_message)
|
|
393
393
|
|
|
394
394
|
return commit_message
|
|
395
395
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: git-commitflow
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.1
|
|
4
4
|
Summary: A git add/commit/push helper
|
|
5
5
|
Home-page: https://github.com/jamescherti/git-commitflow
|
|
6
6
|
Author: James Cherti
|
|
@@ -27,6 +27,7 @@ Dynamic: classifier
|
|
|
27
27
|
Dynamic: description
|
|
28
28
|
Dynamic: description-content-type
|
|
29
29
|
Dynamic: home-page
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
Dynamic: requires-dist
|
|
31
32
|
Dynamic: requires-python
|
|
32
33
|
Dynamic: summary
|
|
@@ -39,9 +40,10 @@ Dynamic: summary
|
|
|
39
40
|
The `git-commitflow` tool is an interactive command-line interface that assists with the Git operations.
|
|
40
41
|
|
|
41
42
|
Running `git-commitflow` guides the user through the following interactive steps:
|
|
42
|
-
- Prompting the user to add files (`git add`)
|
|
43
|
-
- Displaying differences to ensure accuracy and prevent mistakes before committing (`git diff`)
|
|
44
|
-
- Prompting the user to enter a commit message and then committing the changes (`git commit`)
|
|
43
|
+
- Prompting the user to add files (`git add`).
|
|
44
|
+
- Displaying differences to ensure accuracy and prevent mistakes before committing (`git diff`).
|
|
45
|
+
- Prompting the user to enter a commit message and then committing the changes (`git commit`).
|
|
46
|
+
- It first attempts to merge using `--ff-only`; if the merge fails, it prompts the user to confirm whether to proceed with a rebase using `--rebase` and `--autostash`. Afterward, it commits the changes.
|
|
45
47
|
- Optional (`-p` flag): Pushing updates to the remote repository (`git push`). The references are only pushed when they have never been pushed before. The `git-commitflow` tool maintains a list of references that have been pushed, preventing multiple pushes of the same reference. This reduces unnecessary pushes.
|
|
46
48
|
|
|
47
49
|
One significant benefit of the `git-commitflow` tool is that it enhances the user's awareness and control over their changes before committing. This reduces the likelihood of including unintended files or alterations in commits, promoting a cleaner and more organized version history.
|
|
@@ -23,7 +23,7 @@ from setuptools import find_packages, setup
|
|
|
23
23
|
|
|
24
24
|
setup(
|
|
25
25
|
name="git-commitflow",
|
|
26
|
-
version="1.
|
|
26
|
+
version="1.1.1",
|
|
27
27
|
packages=find_packages(),
|
|
28
28
|
description="A git add/commit/push helper",
|
|
29
29
|
long_description=((Path(__file__).parent.resolve().joinpath("README.md"))
|
|
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
|