Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Commander
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
INS Courses
AutPy
Commander
Commits
4a489464
Commit
4a489464
authored
1 year ago
by
Florian Bruhin
Browse files
Options
Downloads
Patches
Plain Diff
Add a commit selector
parent
97b5c875
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
commander/gui/git.py
+12
-2
12 additions, 2 deletions
commander/gui/git.py
commander/gui/mainwidget.py
+7
-0
7 additions, 0 deletions
commander/gui/mainwidget.py
commander/gui/selectors.py
+25
-4
25 additions, 4 deletions
commander/gui/selectors.py
with
44 additions
and
6 deletions
commander/gui/git.py
+
12
−
2
View file @
4a489464
...
...
@@ -90,7 +90,8 @@ class GitFetcher(QObject):
class
HistoryView
(
QTableWidget
):
_COLUMNS
=
[
"
commit
"
,
"
date
"
,
"
message
"
]
checked_out
=
pyqtSignal
()
checked_out
=
pyqtSignal
(
str
)
commit_history_loaded
=
pyqtSignal
(
list
)
def
__init__
(
self
,
parent
:
QWidget
=
None
)
->
None
:
super
().
__init__
(
parent
)
...
...
@@ -111,6 +112,11 @@ class HistoryView(QTableWidget):
self
.
_branch
=
branch
self
.
update
()
@pyqtSlot
(
str
)
def
on_commit_changed
(
self
,
commit
:
str
)
->
None
:
self
.
_checkout
(
commit
)
self
.
checked_out
.
emit
(
commit
)
@pyqtSlot
(
pathlib
.
Path
)
def
on_folder_changed
(
self
,
path
:
pathlib
.
Path
)
->
None
:
self
.
_folder
=
path
...
...
@@ -122,7 +128,7 @@ class HistoryView(QTableWidget):
assert
self
.
_branch
is
not
None
commit
=
self
.
item
(
row
,
0
).
data
(
Qt
.
ItemDataRole
.
DisplayRole
)
self
.
_checkout
(
commit
)
self
.
checked_out
.
emit
()
self
.
checked_out
.
emit
(
commit
)
def
_folder_commits
(
self
)
->
set
[
str
]:
"""
Get a set of commits touching the current folder.
"""
...
...
@@ -146,11 +152,13 @@ class HistoryView(QTableWidget):
current
=
REPO
.
head_short_sha
()
folder_commits
=
self
.
_folder_commits
()
commits
=
[]
for
r
,
line
in
enumerate
(
lines
):
for
c
,
data
in
enumerate
(
line
.
split
(
"
,
"
,
maxsplit
=
2
)):
item
=
QTableWidgetItem
(
data
)
if
c
==
0
:
commits
.
append
(
data
)
if
data
==
current
:
item
.
setFont
(
self
.
_bold_font
)
if
data
not
in
folder_commits
:
...
...
@@ -159,3 +167,5 @@ class HistoryView(QTableWidget):
self
.
setHorizontalHeaderLabels
(
self
.
_COLUMNS
)
self
.
resizeColumnsToContents
()
self
.
commit_history_loaded
.
emit
(
commits
)
This diff is collapsed.
Click to expand it.
commander/gui/mainwidget.py
+
7
−
0
View file @
4a489464
...
...
@@ -90,9 +90,16 @@ class MainWidget(QWidget):
self
.
selectors
.
folder
.
on_branch_changed
)
self
.
selectors
.
branch
.
branch_changed
.
connect
(
self
.
history
.
on_branch_changed
)
self
.
selectors
.
commit
.
commit_changed
.
connect
(
self
.
history
.
on_commit_changed
)
self
.
selectors
.
test
.
test_changed
.
connect
(
self
.
overview
.
on_test_changed
)
self
.
overview
.
test_activated
.
connect
(
self
.
selectors
.
test
.
on_test_activated
)
self
.
history
.
checked_out
.
connect
(
self
.
selectors
.
folder
.
on_branch_changed
)
self
.
history
.
commit_history_loaded
.
connect
(
self
.
selectors
.
commit
.
on_commit_history_loaded
)
self
.
history
.
checked_out
.
connect
(
self
.
selectors
.
commit
.
on_commit_history_checked_out
)
QApplication
.
instance
().
focusChanged
.
connect
(
self
.
selectors
.
on_focus_changed
)
self
.
selectors
.
open_defaults
()
...
...
This diff is collapsed.
Click to expand it.
commander/gui/selectors.py
+
25
−
4
View file @
4a489464
...
...
@@ -22,7 +22,6 @@ from autpy import submissions
class
Selector
(
QLineEdit
):
SHORTCUT
=
None
def
__init__
(
self
,
parent
:
QWidget
=
None
)
->
None
:
...
...
@@ -74,7 +73,6 @@ class Selector(QLineEdit):
class
FolderSelector
(
Selector
):
folder_changed
=
pyqtSignal
(
pathlib
.
Path
)
SHORTCUT
=
QKeySequence
(
"
Ctrl+F
"
)
...
...
@@ -105,7 +103,6 @@ class FolderSelector(Selector):
class
BranchSelector
(
Selector
):
branch_changed
=
pyqtSignal
(
str
)
SHORTCUT
=
QKeySequence
(
"
Ctrl+B
"
)
...
...
@@ -122,8 +119,30 @@ class BranchSelector(Selector):
self
.
branch_changed
.
emit
(
text
)
class
TestSelector
(
Selector
):
class
CommitSelector
(
Selector
):
commit_changed
=
pyqtSignal
(
str
)
SHORTCUT
=
QKeySequence
(
"
Ctrl+S
"
)
@pyqtSlot
(
list
)
def
on_commit_history_loaded
(
self
,
data
:
list
[
str
])
->
None
:
self
.
data
=
data
self
.
update_completer
()
@pyqtSlot
(
str
)
def
on_commit_history_checked_out
(
self
,
commit
:
str
)
->
None
:
self
.
setText
(
commit
)
def
_get_data
(
self
)
->
list
[
str
]:
return
self
.
data
# nop
def
_default_value
(
self
)
->
str
:
return
""
def
accept_text
(
self
,
text
:
str
)
->
None
:
self
.
commit_changed
.
emit
(
text
)
class
TestSelector
(
Selector
):
test_changed
=
pyqtSignal
(
str
)
SHORTCUT
=
QKeySequence
(
"
Ctrl+T
"
)
...
...
@@ -172,6 +191,7 @@ class SelectorGrid(QWidget):
self
.
setLayout
(
layout
)
layout
.
setContentsMargins
(
0
,
0
,
0
,
0
)
self
.
commit
=
CommitSelector
()
self
.
test
=
TestSelector
()
self
.
folder
=
FolderSelector
()
self
.
branch
=
BranchSelector
()
...
...
@@ -179,6 +199,7 @@ class SelectorGrid(QWidget):
items
=
[
(
"
<b>Focus</b> (Ctrl+1/2/3/4/5):
"
,
self
.
focus
),
(
"
<b>Commit</b> (Ctrl+S):
"
,
self
.
commit
),
(
"
<b>Test</b> (Ctrl+T):
"
,
self
.
test
),
(
"
<b>Folder</b> (Ctrl+F):
"
,
self
.
folder
),
(
"
<b>Branch</b> (Ctrl+B):
"
,
self
.
branch
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment