Skip to content

Commit 5418c8d

Browse files
author
Gianvito Taneburgo
committed
pre-merge
1 parent f499b5d commit 5418c8d

File tree

8 files changed

+29
-1
lines changed

8 files changed

+29
-1
lines changed

LICENSE

100644100755
File mode changed.

README.md

100644100755
File mode changed.

bin/bc-env.sh

100644100755
File mode changed.

bin/git-bc-show-eligible

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
# coding=utf-8
33

44
from __future__ import unicode_literals
@@ -8,6 +8,10 @@ import argparse
88
import pygit2
99
import sys
1010
import re
11+
import typing
12+
import os
13+
14+
EXCLUDES_PATH = os.path.join(os.path.expanduser("~"), '.excludes_show_eligible')
1115

1216
def find_toplevel():
1317
try:
@@ -51,6 +55,21 @@ def find_unpicked(repo, from_commit, to_commit, since_commit, show_all):
5155
if since_commit and commit.id == since_commit.id:
5256
break
5357

58+
def read_excludes() -> typing.List[str]:
59+
if not os.path.isfile(EXCLUDES_PATH):
60+
return []
61+
with open(EXCLUDES_PATH, 'r') as f:
62+
return f.read().splitlines()
63+
64+
def add_exclude_hash(excludes: typing.List[str], commit: str) -> None:
65+
if commit in excludes:
66+
print(f'Commit {commit} already in the exclude list ({EXCLUDES_PATH}).')
67+
sys.exit(1)
68+
with open(EXCLUDES_PATH, 'at') as f:
69+
f.write(commit + '\n')
70+
print(f'Hash {commit} added successfully.')
71+
exit(0)
72+
5473
def main():
5574
parser = argparse.ArgumentParser(description='Show commits, eligible for cherry-picking')
5675
parser.add_argument('branch', metavar='BRANCH', help='Name for the branch to check against',
@@ -59,8 +78,11 @@ def main():
5978
default='HEAD', nargs='?')
6079
parser.add_argument('--since', metavar='COMMIT', help='Start checking since specified commit')
6180
parser.add_argument('--all', action='store_true', help='Show commits from all users')
81+
parser.add_argument('--add-to-exclude-list', metavar='COMMIT', help='Add a merge commit hash so it, '
82+
f'and its children, no longer are displayed in the output. This is saved in "{EXCLUDES_PATH}".')
6283

6384
top = find_toplevel()
85+
excludes = read_excludes()
6486

6587
if not top:
6688
print('The current folder is not a valid git repository')
@@ -69,6 +91,9 @@ def main():
6991
args = parser.parse_args()
7092
repo = pygit2.Repository(top)
7193

94+
if args.add_to_exclude_list:
95+
add_exclude_hash(excludes, args.add_to_exclude_list)
96+
7297
try:
7398
from_commit = repo.revparse_single(args.branch)
7499
except:
@@ -129,6 +154,9 @@ def main():
129154
child_commits = group[1:-1]
130155
last_child_commit = group[-1] if len(group) > 1 else ''
131156

157+
if [e for e in excludes if e in merge]:
158+
continue
159+
132160
print(merge)
133161

134162
for child in child_commits:

man/git-bc-cherry-pick.1.ronn

100644100755
File mode changed.

man/git-bc-log.1.ronn

100644100755
File mode changed.

man/man1/git-bc-cherry-pick.1

100644100755
File mode changed.

man/man1/git-bc-log.1

100644100755
File mode changed.

0 commit comments

Comments
 (0)