From e0fe99825fb16ddec92bfd711d09965dca628388 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Tue, 5 Sep 2023 11:38:43 +0200 Subject: [PATCH 1/2] react to library not present in a nicer way --- Iceberg-Libgit/IceLibgitRepository.class.st | 5 +++++ .../IceTipRepositoriesBrowser.class.st | 19 ++++++++++++++++++- Iceberg-TipUI/IceTipRepositoryModel.class.st | 17 +++++++++++++---- Iceberg-TipUI/IceTipStyleContributor.class.st | 19 +++++++++++-------- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/Iceberg-Libgit/IceLibgitRepository.class.st b/Iceberg-Libgit/IceLibgitRepository.class.st index 141d9024f0..fe29a55322 100644 --- a/Iceberg-Libgit/IceLibgitRepository.class.st +++ b/Iceberg-Libgit/IceLibgitRepository.class.st @@ -768,6 +768,11 @@ IceLibgitRepository >> remoteTrackedBranches [ { #category : #'API - remotes' } IceLibgitRepository >> remotes [ + LGitLibrary uniqueInstance isAvailable + ifFalse: [ + 'No libgit2 available, skipping.' crTrace. + ^ #() ]. + self handleLibgitError: [ | gitRemotes | self isValid ifFalse: [ ^ #() ]. gitRemotes := self repositoryHandle allRemotes. diff --git a/Iceberg-TipUI/IceTipRepositoriesBrowser.class.st b/Iceberg-TipUI/IceTipRepositoriesBrowser.class.st index 7eb4a029e1..2483dd4c58 100644 --- a/Iceberg-TipUI/IceTipRepositoriesBrowser.class.st +++ b/Iceberg-TipUI/IceTipRepositoriesBrowser.class.st @@ -9,7 +9,8 @@ Class { #superclass : #IceTipBrowser, #instVars : [ 'currentGroupPanel', - 'repositoryNotebook' + 'repositoryNotebook', + 'notifyPanel' ], #category : #'Iceberg-TipUI-View-Repository' } @@ -103,6 +104,14 @@ IceTipRepositoriesBrowser class >> newOnRepositoryProvider: aProvider [ yourself ] +{ #category : #initialization } +IceTipRepositoriesBrowser >> addLibGitNotAvailableWarning [ + + notifyPanel layout add: (notifyPanel newLabel + label: 'There is no libgit2 available in your system! Please verify everything is fine before continue.'; + yourself) +] + { #category : #initialization } IceTipRepositoriesBrowser >> connectPresenters [ @@ -127,6 +136,7 @@ IceTipRepositoriesBrowser >> defaultKeyboardFocus [ IceTipRepositoriesBrowser >> defaultLayout [ ^ SpBoxLayout newTopToBottom + add: notifyPanel expand: false; add: repositoryNotebook; yourself ] @@ -155,6 +165,10 @@ IceTipRepositoriesBrowser >> initialExtentForWindow [ { #category : #initialization } IceTipRepositoriesBrowser >> initializePresenters [ + notifyPanel := self newPresenter. + notifyPanel layout: SpBoxLayout newVertical. + notifyPanel addStyle: 'libgit2NotAvailable'. + repositoryNotebook := self newNotebook ] @@ -259,6 +273,9 @@ IceTipRepositoriesBrowser >> titleForWindow [ { #category : #initialization } IceTipRepositoriesBrowser >> updatePresenter [ + LGitLibrary uniqueInstance isAvailable + ifFalse: [ self addLibGitNotAvailableWarning ]. + self model repositoryGroups do: [ :group | repositoryNotebook addPageTitle: group label diff --git a/Iceberg-TipUI/IceTipRepositoryModel.class.st b/Iceberg-TipUI/IceTipRepositoryModel.class.st index a7eb6937d0..5d75754d1b 100644 --- a/Iceberg-TipUI/IceTipRepositoryModel.class.st +++ b/Iceberg-TipUI/IceTipRepositoryModel.class.st @@ -57,9 +57,11 @@ IceTipRepositoryModel >> branchModelFor: aBranch [ { #category : #accessing } IceTipRepositoryModel >> branchName [ - self entity isMissing ifTrue: [ ^ self class unknownBranchLabel ]. - ^ self entity head description. + (self isLibGitAvailable not or: [ self entity isMissing ]) + ifTrue: [ ^ self class unknownBranchLabel ]. + + ^ self entity head description ] { #category : #accessing } @@ -110,7 +112,7 @@ IceTipRepositoryModel >> description [ | text | text := self displayString. - self entity isModified + (self isLibGitAvailable and: [ self entity isModified ]) ifTrue: [ text := '*', text ]. ^ text ] @@ -118,7 +120,7 @@ IceTipRepositoryModel >> description [ { #category : #accessing } IceTipRepositoryModel >> descriptionDecorator [ - self entity isModified + (self isLibGitAvailable and: [ self entity isModified ]) ifTrue: [ ^ IceTipDescriptionDecorator modified ]. ^ super descriptionDecorator ] @@ -175,6 +177,12 @@ IceTipRepositoryModel >> isDetached [ or: [ self entity head isDetached ] ] +{ #category : #'private - testing' } +IceTipRepositoryModel >> isLibGitAvailable [ + + ^ LGitLibrary uniqueInstance isAvailable +] + { #category : #'private - testing' } IceTipRepositoryModel >> isLoaded [ ^ self entity loadedPackages notEmpty @@ -425,6 +433,7 @@ IceTipRepositoryModel >> status [ | status incoming outgoing | self verifyDirectoryStructureIfMissing: [ :message | ^ message asString ]. + self isLibGitAvailable ifFalse: [ ^ 'Unknown (No libgit2)' ]. entity workingCopy workingCopyState isUnknownCommitState ifTrue: [ ^ entity workingCopy workingCopyState description ]. diff --git a/Iceberg-TipUI/IceTipStyleContributor.class.st b/Iceberg-TipUI/IceTipStyleContributor.class.st index 44cbcc047b..57fadcd53a 100644 --- a/Iceberg-TipUI/IceTipStyleContributor.class.st +++ b/Iceberg-TipUI/IceTipStyleContributor.class.st @@ -13,13 +13,16 @@ Class { IceTipStyleContributor >> styleSheetContribution [ ^ SpStyle newApplication - addClass: 'textInputField' with: [ :textClass | - textClass addClass: 'iceTipReadonly' with: [ :iceTipReadonly | - iceTipReadonly addPropertyDrawWith: [ :draw | draw color: Color transparent ] ]] ; - addClass: 'text' with: [ :textClass | - textClass addClass: 'iceTipReadonly' with: [ :iceTipReadonly | - iceTipReadonly addPropertyDrawWith: [ :draw | draw color: Color transparent ]. - textClass addClass: 'iceTipText4Lines' with: [ :iceTipText4Lines | - iceTipText4Lines addPropertyGeometryWith: [ :geo | geo height: 80 ] ] ] ]; + addClass: 'libgit2NotAvailable' with: [ :aClass | aClass + addPropertyDrawWith: [ :draw | draw backgroundColor: Color orange ]; + addPropertyFontWith: [ :font | font color: Color white ] ]; + addClass: 'textInputField' with: [ :textClass | textClass + addClass: 'iceTipReadonly' with: [ :iceTipReadonly | iceTipReadonly + addPropertyDrawWith: [ :draw | draw color: Color transparent ] ] ]; + addClass: 'text' with: [ :textClass | textClass + addClass: 'iceTipReadonly' with: [ :iceTipReadonly | iceTipReadonly + addPropertyDrawWith: [ :draw | draw color: Color transparent ]; + addClass: 'iceTipText4Lines' with: [ :iceTipText4Lines | iceTipText4Lines + addPropertyGeometryWith: [ :geo | geo height: 80 ] ] ] ]; yourself ] From 334248bf2bd9e1991a76af0728827793ad6dc077 Mon Sep 17 00:00:00 2001 From: Esteban Lorenzano Date: Wed, 6 Sep 2023 15:29:01 +0200 Subject: [PATCH 2/2] bindings update to 3.0.7 --- BaselineOfIceberg/BaselineOfIceberg.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaselineOfIceberg/BaselineOfIceberg.class.st b/BaselineOfIceberg/BaselineOfIceberg.class.st index f69d9bdebe..141e9776f5 100644 --- a/BaselineOfIceberg/BaselineOfIceberg.class.st +++ b/BaselineOfIceberg/BaselineOfIceberg.class.st @@ -76,7 +76,7 @@ BaselineOfIceberg >> libgit: spec [ baseline: 'LibGit' with: [ spec - repository: 'github://pharo-vcs/libgit2-pharo-bindings:v3.0.6'; + repository: 'github://pharo-vcs/libgit2-pharo-bindings:v3.0.7'; loads: 'default' ]. spec project: 'LibGit-Tests'