Skip to content

Commit

Permalink
allow force push
Browse files Browse the repository at this point in the history
  • Loading branch information
vdelachaux committed Nov 23, 2023
1 parent 81df65e commit cde182f
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 108 deletions.
52 changes: 40 additions & 12 deletions Project/Sources/Classes/Git.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -539,24 +539,52 @@ Function pull($rebase : Boolean; $stash : Boolean) : Boolean
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function push($origin : Text; $branch : Text) : Boolean

If (This:C1470.remotes.length=0)
var $c : Collection

$c:=["push"]

If (Count parameters:C259>=2)

TRACE:C157 // No remote
$c.push($origin)
$c.push($branch)

Else

If (Count parameters:C259>=2)

return This:C1470.execute("push "+$origin+" "+$branch+" -q")

Else

// FIXME:What if "master" is not the main branch?
return This:C1470.execute("push origin master -q")

End if
// FIXME:What if "master" is not the main branch?
$c.push("origin master")

End if

$c.push("--tags")
$c.push("--quiet")

return This:C1470.execute($c.join(" "))

// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function forcePush($origin : Text; $branch : Text) : Boolean

var $c : Collection

$c:=["push"]

If (Count parameters:C259>=2)

$c.push($origin)
$c.push($branch)

Else

// FIXME:What if "master" is not the main branch?
$c.push("origin master")

End if

$c.push("--force-with-lease")
$c.push("--tags")
$c.push("--quiet")

return This:C1470.execute($c.join(" "))

//MARK:-branch
// === === === === === === === === === === === === === === === === === === === === === === === === === ===
Function branch($whatToDo : Text; $name : Text; $newName : Text)
Expand Down
7 changes: 6 additions & 1 deletion Project/Sources/Classes/_GIT_Controller.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,12 @@ Function handleEvents($e : cs:C1710.evt)
//==============================================
: (This:C1470.push.catch($e; On Clicked:K2:4))

This:C1470.pushDialog.show()
$git.execute("config push.followTags")

This:C1470.pushDialog.show({\
tags: $git.result#"false"; \
force: False:C215\
})

//==============================================
: (This:C1470.open.catch($e; On Clicked:K2:4))
Expand Down
55 changes: 46 additions & 9 deletions Project/Sources/Classes/onBoard.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,28 @@ property instances : Collection

Class constructor($widget : Text; $form : Text)

ARRAY TEXT:C222($names; 0x0000)
FORM GET NAMES:C1167($names; $form)
ASSERT:C1129(Size of array:C274($names)=1; "Form not found: "+$form)

ARRAY LONGINT:C221($pages; 0x0000)
ARRAY POINTER:C280($pointers; 0x0000)
FORM GET OBJECTS:C898($names; $pointers; $pages; Form all pages:K67:7)

var $indx : Integer
$indx:=Find in array:C230($names; $widget)

If (Asserted:C1132($indx>0; "Widget not found: "+$widget))

ASSERT:C1129($pages{$indx}=0; "WARNING: The widget is not on page 0")

End if

This:C1470.form:=$form // The form to use as a sub-form

This:C1470.instances:=[{\
name: $widget; \
data: {}\
data: {ACCEPTED: False:C215; CANCELLED: False:C215}\
}]

// Make sure the widget is invisible
Expand All @@ -32,6 +49,23 @@ Function get name() : Text

End if

// === === === === === === === === === === === === === === === === === ===
Function get instance() : Object

var $form; $name : Text
var $ptr : Pointer
var $data : Object

$name:=OBJECT Get name:C1087(Object current:K67:2)

// Get the name of the current displayed sub-form
OBJECT GET SUBFORM:C1139(*; $name; $ptr; $form)

// Get the data associated with the subform (Form)
$data:=OBJECT Get value:C1743($name)

return {name: $name; form: $form; data: $data}

// === === === === === === === === === === === === === === === === === ===
// Displays widget
Function show($data : Object)
Expand Down Expand Up @@ -61,9 +95,16 @@ Function show($data : Object)
// Reset
For each ($key; $instance.data)

If ($key="parent")\
| ($key="me")
If ($key="me")

continue

End if

If ($key="ACCEPTED")\
| ($key="CANCELLED")

$instance.data[$key]:=False:C215
continue

End if
Expand Down Expand Up @@ -100,21 +141,18 @@ Function show($data : Object)
// === === === === === === === === === === === === === === === === === ===
Function close()

Form:C1466.close:=True:C214
CALL SUBFORM CONTAINER:C1086(-1)

// === === === === === === === === === === === === === === === === === ===
Function accept()

Form:C1466.ok:=True:C214
Form:C1466.close:=True:C214
Form:C1466.ACCEPTED:=True:C214
CALL SUBFORM CONTAINER:C1086(-1)

// === === === === === === === === === === === === === === === === === ===
Function cancel()

Form:C1466.cancel:=True:C214
Form:C1466.close:=True:C214
Form:C1466.CANCELLED:=True:C214
CALL SUBFORM CONTAINER:C1086(-1)

// === === === === === === === === === === === === === === === === === ===
Expand Down Expand Up @@ -206,7 +244,6 @@ Function _setProgress($value : Integer; $message : Text)
End if

// === === === === === === === === === === === === === === === === === ===

// Generic asignment management when loading the sub-form
Function onLoad()

Expand Down
16 changes: 8 additions & 8 deletions Project/Sources/Forms/ALERT/form.4DForm
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"title": {
"type": "text",
"top": 70,
"left": 108,
"width": 365,
"left": 138,
"width": 335,
"height": 16,
"fontTheme": "main",
"text": "Form.title"
Expand Down Expand Up @@ -65,24 +65,24 @@
"type": "text",
"text": "Form.additional",
"top": 94,
"left": 108,
"width": 359,
"left": 138,
"width": 329,
"height": 91,
"fontTheme": "additional"
},
"Static Picture1": {
"type": "picture",
"top": 70,
"left": 68,
"width": 32,
"height": 32,
"picture": "/RESOURCES/Images/git.png",
"width": 64,
"height": 64,
"picture": "/.PRODUCT_RESOURCES/Images/alert.png",
"pictureFormat": "scaled"
}
}
}
],
"geometryStamp": 143,
"geometryStamp": 150,
"editor": {
"activeView": "View 1",
"defaultView": "View 1",
Expand Down
104 changes: 36 additions & 68 deletions Project/Sources/Forms/GIT/ObjectMethods/embeddedDialogs.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,25 @@ $e:=FORM Event:C1606

If ($e.code<0)

var $name : Text
$name:=OBJECT Get name:C1087(Object current:K67:2)

// Get data associated with the subform
var $form : Text
var $ptr : Pointer // The name of the current displayed sub-form
OBJECT GET SUBFORM:C1139(*; $name; $ptr; $form)

// Get data associated with the subform
var $data : Object
$data:=OBJECT Get value:C1743($name)

/*
Doing things, if need be
Possibly call "return" to avoid executing the "Standard actions" code that follows.
*/

var $me : Object
$me:=formGetInstance
$me:=OBJECT Get value:C1743(OBJECT Get name:C1087).me.instance.data

// MARK:-Specific actions
var $form : Object
$form:=formGetInstance

var $git : cs:C1710.Git
$git:=$me.Git
$git:=$form.Git

// MARK:Specific actions
Case of

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
: (Bool:C1537($data.cancel))
: ($me.CANCELLED)

OBJECT SET VISIBLE:C603(*; $name; False:C215)
return
// <NOTHING MORE TO DO>

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
: (Bool:C1537($data.push))

OBJECT SET VISIBLE:C603(*; $name; False:C215)
: (Bool:C1537($me.push))

If ($git.remotes.length=0)

Expand All @@ -50,11 +30,11 @@ Possibly call "return" to avoid executing the "Standard actions" code that follo

If (Not:C34($gh.available))

$me.alertDialog.show({\
$form.alertDialog.show({\
title: $gh.lastError; \
additional: "Installation instructions can be found at:\n\nhttps://github.com/cli/cli#installation"})

return
return // 📌 Avoid executing code that follows

End if

Expand All @@ -76,63 +56,51 @@ Possibly call "return" to avoid executing the "Standard actions" code that follo

Else

$git.push()

If ($me.force)

$git.forcePush()

Else

$git.push()

End if
End if

If ($git.success)

$me.onActivate()
$form.onActivate()

Else

$me.alertDialog.show({\
$form.alertDialog.show({\
title: "Error"; \
additional: $git.error})

return // 📌 Avoid executing code that follows

End if

return

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
: (Bool:C1537($data.pull))
: (Bool:C1537($me.pull))

OBJECT SET VISIBLE:C603(*; $name; False:C215)
Form:C1466.stash:=Bool:C1537($me.stash)

Form:C1466.stash:=Bool:C1537($data.stash)

$git.pull(Bool:C1537($data.rebase); Form:C1466.stash)
$me.onActivate()
$git.pull(Bool:C1537($me.rebase); Form:C1466.stash)
$form.onActivate()

RELOAD PROJECT:C1739
return

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
Else

// A "Case of" statement should never omit "Else"

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
End case

// MARK:Standard actions
Case of

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
: (Bool:C1537($data.close))

OBJECT SET VISIBLE:C603(*; $name; False:C215)

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
Else

// A "Case of" statement should never omit "Else"

//╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍╍
End case

Else
// MARK:-Standard actions
$me.me.hide()

// Standard form events
return

End if
End if

// MARK:-Standard (positive) form events

//
Loading

0 comments on commit cde182f

Please sign in to comment.