mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-04 05:47:17 +08:00
#326 write protection
This commit is contained in:
parent
f7d3117bdd
commit
dcc196198b
|
@ -114,8 +114,9 @@ CONSTANTS: BEGIN OF gc_event_state,
|
|||
END OF gc_event_state.
|
||||
|
||||
CONSTANTS: BEGIN OF gc_html_opt,
|
||||
emphas TYPE c VALUE 'E',
|
||||
cancel TYPE c VALUE 'C',
|
||||
emphas TYPE c VALUE 'E',
|
||||
cancel TYPE c VALUE 'C',
|
||||
crossout TYPE c VALUE 'X',
|
||||
END OF gc_html_opt.
|
||||
|
||||
CONSTANTS: BEGIN OF gc_action_type,
|
||||
|
|
|
@ -993,6 +993,10 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
IF lo_repo->is_write_protected( ) = abap_true.
|
||||
lcx_exception=>raise( 'Cannot reset. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
CALL FUNCTION 'POPUP_TO_CONFIRM'
|
||||
EXPORTING
|
||||
titlebar = 'Warning'
|
||||
|
@ -1056,6 +1060,11 @@ CLASS lcl_gui_router IMPLEMENTATION.
|
|||
DATA: lo_repo TYPE REF TO lcl_repo_online.
|
||||
|
||||
lo_repo ?= lcl_app=>repo_srv( )->get( iv_key ).
|
||||
|
||||
IF lo_repo->is_write_protected( ) = abap_true.
|
||||
lcx_exception=>raise( 'Cannot pull. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
lo_repo->refresh( ).
|
||||
lo_repo->deserialize( ).
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ CLASS lcl_html_helper DEFINITION FINAL.
|
|||
|
||||
METHODS add_anchor IMPORTING iv_txt TYPE string
|
||||
iv_act TYPE string
|
||||
iv_opt TYPE char1 OPTIONAL
|
||||
iv_opt TYPE clike OPTIONAL
|
||||
iv_typ TYPE char1 DEFAULT gc_action_type-sapevent
|
||||
iv_class TYPE string OPTIONAL.
|
||||
|
||||
|
@ -398,12 +398,15 @@ CLASS lcl_html_helper IMPLEMENTATION.
|
|||
|
||||
lv_class = iv_class.
|
||||
|
||||
IF iv_opt = gc_html_opt-emphas.
|
||||
IF iv_opt ca gc_html_opt-emphas.
|
||||
lv_class = lv_class && ' emphasis' ##NO_TEXT.
|
||||
ENDIF.
|
||||
IF iv_opt = gc_html_opt-cancel.
|
||||
IF iv_opt ca gc_html_opt-cancel.
|
||||
lv_class = lv_class && ' attention' ##NO_TEXT.
|
||||
ENDIF.
|
||||
IF iv_opt ca gc_html_opt-crossout.
|
||||
lv_class = lv_class && ' crossout grey' ##NO_TEXT.
|
||||
ENDIF.
|
||||
IF lv_class IS NOT INITIAL.
|
||||
SHIFT lv_class LEFT DELETING LEADING space.
|
||||
lv_class = | class="{ lv_class }"|.
|
||||
|
|
|
@ -268,6 +268,7 @@ CLASS lcl_gui_page_super IMPLEMENTATION.
|
|||
_add '.grey { color: lightgrey !important; }'.
|
||||
_add '.emphasis { font-weight: bold !important; }'.
|
||||
_add '.attention { color: red !important; }'.
|
||||
_add '.crossout { text-decoration: line-through !important; }'.
|
||||
_add '.right { text-align:right; }'.
|
||||
_add '.paddings { padding: 0.5em 0.5em; }'.
|
||||
|
||||
|
@ -405,24 +406,8 @@ CLASS lcl_gui_page_super IMPLEMENTATION.
|
|||
_add ' background-color: #f8f0d8;'.
|
||||
_add '}'.
|
||||
|
||||
|
||||
" Other and outdated (?) styles
|
||||
_add '/* MISC AND REFACTOR */'.
|
||||
_add 'a.grey:link {color: grey; font-size: smaller;}'.
|
||||
_add 'a.grey:visited {color: grey; font-size: smaller;}'.
|
||||
_add 'a.plain:link {color: black; text-decoration: none;}'.
|
||||
_add 'a.plain:visited {color: black; text-decoration: none;}'.
|
||||
_add 'a.bkg:link {color: #E8E8E8;}'.
|
||||
_add 'a.bkg:visited {color: #E8E8E8;}'.
|
||||
_add 'h1 {display: inline;}'.
|
||||
_add 'h2 {display: inline;}'.
|
||||
_add 'h3 {'.
|
||||
_add ' display: inline;'.
|
||||
_add ' color: grey;'.
|
||||
_add ' font-weight:normal;'.
|
||||
_add ' font-size: smaller;'.
|
||||
_add '}'.
|
||||
|
||||
_add '.hidden-submit {'.
|
||||
_add ' border: 0 none;'.
|
||||
_add ' height: 0;'.
|
||||
|
|
|
@ -207,6 +207,8 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
|
||||
DATA: lo_toolbar TYPE REF TO lcl_html_toolbar,
|
||||
lv_key TYPE lcl_persistence_db=>ty_value,
|
||||
lv_wp_opt LIKE gc_html_opt-crossout,
|
||||
lv_pull_opt LIKE gc_html_opt-crossout,
|
||||
lo_sub TYPE REF TO lcl_html_toolbar,
|
||||
lo_branch TYPE REF TO lcl_html_toolbar,
|
||||
lo_repo_online TYPE REF TO lcl_repo_online.
|
||||
|
@ -217,6 +219,16 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
|
||||
lv_key = io_repo->get_key( ).
|
||||
|
||||
IF io_repo->is_offline( ) = abap_false.
|
||||
lo_repo_online ?= io_repo.
|
||||
IF lo_repo_online->is_write_protected( ) = abap_true.
|
||||
lv_wp_opt = gc_html_opt-crossout.
|
||||
lv_pull_opt = gc_html_opt-crossout.
|
||||
ELSE.
|
||||
lv_pull_opt = gc_html_opt-emphas.
|
||||
ENDIF.
|
||||
ENDIF.
|
||||
|
||||
IF io_repo->is_offline( ) = abap_true.
|
||||
lo_toolbar->add( iv_txt = 'Import ZIP'
|
||||
iv_act = |zipimport?{ lv_key }|
|
||||
|
@ -225,12 +237,11 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
iv_act = |zipexport?{ lv_key }|
|
||||
iv_opt = gc_html_opt-emphas ).
|
||||
ELSE.
|
||||
lo_repo_online ?= io_repo.
|
||||
TRY.
|
||||
IF lo_repo_online->get_sha1_remote( ) <> lo_repo_online->get_sha1_local( ).
|
||||
lo_toolbar->add( iv_txt = 'Pull'
|
||||
iv_act = |pull?{ lv_key }|
|
||||
iv_opt = gc_html_opt-emphas ).
|
||||
iv_opt = lv_pull_opt ).
|
||||
ELSEIF lcl_stage_logic=>count( lo_repo_online ) > 0.
|
||||
lo_toolbar->add( iv_txt = 'Stage'
|
||||
iv_act = |stage?{ lv_key }|
|
||||
|
@ -248,7 +259,8 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
lo_branch->add( iv_txt = 'Overview'
|
||||
iv_act = |branch_overview?{ lv_key }| ).
|
||||
lo_branch->add( iv_txt = 'Switch'
|
||||
iv_act = |{ c_actions-switch_branch }?{ lv_key }| ).
|
||||
iv_act = |{ c_actions-switch_branch }?{ lv_key }|
|
||||
iv_opt = lv_wp_opt ).
|
||||
lo_branch->add( iv_txt = 'Create'
|
||||
iv_act = |create_branch?{ lv_key }| ).
|
||||
lo_branch->add( iv_txt = 'Delete'
|
||||
|
@ -257,7 +269,8 @@ CLASS lcl_gui_page_main IMPLEMENTATION.
|
|||
io_sub = lo_branch ) ##NO_TEXT.
|
||||
|
||||
lo_sub->add( iv_txt = 'Reset local'
|
||||
iv_act = |reset?{ lv_key }| ).
|
||||
iv_act = |reset?{ lv_key }|
|
||||
iv_opt = lv_wp_opt ).
|
||||
lo_sub->add( iv_txt = 'Background mode'
|
||||
iv_act = |background?{ lv_key }| ).
|
||||
ELSE.
|
||||
|
|
|
@ -105,7 +105,8 @@ CLASS lcl_persistence_repo DEFINITION FINAL.
|
|||
offline TYPE sap_bool,
|
||||
local_checksums TYPE ty_local_checksum_tt,
|
||||
master_language TYPE spras,
|
||||
head_branch TYPE string,
|
||||
head_branch TYPE string, " HEAD symref of the repo, master branch
|
||||
write_protect TYPE sap_bool, " Deny destructive ops: pull, switch branch ...
|
||||
END OF ty_repo_xml.
|
||||
|
||||
TYPES: BEGIN OF ty_repo,
|
||||
|
|
|
@ -83,6 +83,8 @@ CLASS lcl_repo_online DEFINITION INHERITING FROM lcl_repo FINAL.
|
|||
RETURNING VALUE(rv_name) TYPE lcl_persistence_repo=>ty_repo-branch_name,
|
||||
get_head_branch_name
|
||||
RETURNING VALUE(rv_name) TYPE lcl_persistence_repo=>ty_repo-head_branch,
|
||||
is_write_protected
|
||||
RETURNING VALUE(rv_yes) TYPE sap_bool,
|
||||
get_branches
|
||||
RETURNING VALUE(ro_branches) TYPE REF TO lcl_git_branch_list,
|
||||
set_url
|
||||
|
|
|
@ -49,6 +49,10 @@ CLASS lcl_repo_online IMPLEMENTATION.
|
|||
|
||||
METHOD deserialize.
|
||||
|
||||
IF ms_data-write_protect = abap_true.
|
||||
lcx_exception=>raise( 'Cannot deserialize. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
initialize( ).
|
||||
|
||||
super->deserialize( ).
|
||||
|
@ -122,6 +126,10 @@ CLASS lcl_repo_online IMPLEMENTATION.
|
|||
rv_name = ms_data-head_branch.
|
||||
ENDMETHOD. "get_head_branch_name
|
||||
|
||||
METHOD is_write_protected.
|
||||
rv_yes = ms_data-write_protect.
|
||||
ENDMETHOD. "is_write_protected
|
||||
|
||||
METHOD get_branches.
|
||||
IF mo_branches IS NOT BOUND.
|
||||
mo_branches = lcl_git_transport=>branches( get_url( ) ).
|
||||
|
@ -138,6 +146,10 @@ CLASS lcl_repo_online IMPLEMENTATION.
|
|||
|
||||
METHOD set_branch_name.
|
||||
|
||||
IF ms_data-write_protect = abap_true.
|
||||
lcx_exception=>raise( 'Cannot switch branch. Local code is write-protected by repo config' ).
|
||||
ENDIF.
|
||||
|
||||
mv_initialized = abap_false.
|
||||
set( iv_branch_name = iv_branch_name ).
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user