Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert to any single Commit #3040

Closed
ghost opened this issue Nov 5, 2019 · 13 comments · Fixed by #4101
Closed

Revert to any single Commit #3040

ghost opened this issue Nov 5, 2019 · 13 comments · Fixed by #4101
Labels
new feature New feature or request

Comments

@ghost
Copy link

ghost commented Nov 5, 2019

I didn't find this feature and need it so I suggest it: I think it would be useful to be able to revert to any single commit. For this it should be possible to select any existent commit and revert the repository to it.

Related to Issue #753.

@larshp larshp added the new feature New feature or request label Nov 5, 2019
@ghost
Copy link
Author

ghost commented Nov 7, 2019

I could need some help on the following issue: I plan to to ask Git if a commit is existent. We only have a method which fetches all branches from Git, but not anything like it for commits. Does anyone know which request is to be send to Git to ask if a specific commit is existent in a branch?

It would be nice if the short and the long form (SHA1) of commits would be supported.

At the moment I check if the response is returning valid objects via exceptions and this works. But it would be better, if there'd be some check before the request and parsing of the response.

TRY.
        lv_xstring = lo_client->send_receive_close(
          zcl_abapgit_convert=>string_to_xstring_utf8( lv_buffer ) ).

        parse( IMPORTING ev_pack = lv_pack
               CHANGING cv_data  = lv_xstring ).

        IF lv_pack IS INITIAL.
          zcx_abapgit_exception=>raise( 'empty pack' ).
        ENDIF.

        et_objects = zcl_abapgit_git_pack=>decode( lv_pack ).

      CATCH zcx_abapgit_exception INTO DATA(lx_exception).
        IF   io_repo IS BOUND
         AND io_repo->is_offline( ) = abap_false.
          lo_repo ?= io_repo.
          lo_repo->set_commit_name( space ).
        ENDIF.

        IF iv_commit_name IS SUPPLIED.

          zcx_abapgit_exception=>raise( |Invalid commit was given.| ).

        ELSE.

          RAISE EXCEPTION lx_exception.

        ENDIF.

    ENDTRY.

@larshp
Copy link
Member

larshp commented Nov 7, 2019

I dont have much time today or tomorrow, so remind me when I forget to answer 😄

@ghost
Copy link
Author

ghost commented Nov 11, 2019

Added the question above also to Stackoverflow.

@larshp
Copy link
Member

larshp commented Nov 17, 2019

cool

if possible, when doing the PR, try splitting it into multiple steps, I'd like to avoid large PRs

@larshp larshp assigned ghost Nov 17, 2019
@christianguenter2
Copy link
Member

christianguenter2 commented Nov 22, 2019

Few questions:

  • Wouldn't 'Checkout commit' or 'Reset commit', depending on your implementation, be the appropriate git term? Revert a commit means to undo its changes and create a new commit.

  • What happens in the remote repository?

  • What should then happen when you stage and commit?

@ghost
Copy link
Author

ghost commented Nov 22, 2019

  • Yes, indeed; I prefer 'Checkout commit' because at the moment its possible to jump between the commits in a specific branch
  • Nothing, you have to stage the changes after an actual reset
  • On Stage the remote (latest commit) and the development objects of the checked-out commit will be compared with eachother and you can push the 'changes' of the checked-out commit to the remote repo. You have to checkout the latest commit though before you can stage it.

Its like 'git reset --hard ' only without the automation. You first checkout a commit, reset your local repo, checkout the latest commit and then decide to stage it (hard reset remote repo) or reset the local repo to the latest commit via Pull or Reset Local.

@ghost ghost mentioned this issue Nov 28, 2019
larshp pushed a commit that referenced this issue Dec 2, 2019
* Create pull.yml

* Update zcl_abapgit_git_transport.clas.abap

* Update zcl_abapgit_git_transport.clas.abap

* Update pull.yml

* Delete pull.yml

* Improved time conversion

Preparation for #3040

> rename time%3D>get to time%3D>get_unix
> added time conversion from unix to real (get_real)
> added unit tests for time conversion

* abapLint

* Raise cx_static_check and removed exc handling
@larshp
Copy link
Member

larshp commented Dec 12, 2019

sorry, I've removed the linked word file, no need to share files that potentially can contain bad stuff

@ghost ghost mentioned this issue Dec 16, 2019
@ghost
Copy link
Author

ghost commented Jan 21, 2020

Implementation is nearly done. Only one small problem with loading more commits remains: It seems I have to do a http request with the sha of the repo branch and a rising deepen level to get the next 20 sub commits of a branch, which is really time-consuming at a specific deepen level. My first approach was to get sub commits by the last gotten sub commit hash but it seems sometimes not every older commit is being fetched due to the commit hierarchie.

So I suggest we remove the 'load more' function and always load a max. specific amount (e. g. max. last 100 commits).

@larshp
Copy link
Member

larshp commented Jan 22, 2020

some of the new git features supports only getting the commits, and ignoring the blobs, guess it can be used in this case, like for the branch overview page

@ghost
Copy link
Author

ghost commented Jan 22, 2020

Yes, I already reuse the related function like it is being used in branch overview page. But it's just very time-consuming to load over 3500 commits (> 12 Minutes last time I tested it). So we have to limit it. Yet I don't know how to do it.

Additionally branch overview page just filters the commits from the response. Within the response there are still the blobs. So at the moment we don't have a function that only requests the commits.

@ghost
Copy link
Author

ghost commented Jan 26, 2020

@larshp I plan to ship the changes now in the following chunks:

MODEL:
zcl_abapgit_git_commit
zcl_abapgit_git_object
zcl_abapgit_git_porcelain
zcl_abapgit_git_transport
zif_abapgit_persistence
zcl_abapgit_branch_overview
zcl_abapgit_repo
zcl_abapgit_repo_online
zif_abapgit_definitions

GUI:
zcl_abapgit_gui_chunk_lib
zcl_abapgit_gui_page_boverview
zcl_abapgit_gui_page_commit
zcl_abapgit_gui_page_main
zcl_abapgit_gui_page_merge
zcl_abapgit_popups
zcl_abapgit_services_repo
zif_abapgit_popups

LOGIC:
zcl_abapgit_gui_router
zcl_abapgit_gui_view_repo
zcl_abapgit_services_git

Is this ok with you?

@larshp
Copy link
Member

larshp commented Jan 26, 2020

yea, some of the classes I would not expect any changes to, but lets see

This was referenced Jan 26, 2020
@ghost ghost mentioned this issue Apr 20, 2020
larshp added a commit that referenced this issue May 4, 2020
* Create pull.yml

* Update zcl_abapgit_git_transport.clas.abap

* Update zcl_abapgit_git_transport.clas.abap

* Update pull.yml

* Update pull.yml

* Delete pull.yml

* Refactored popup logic

Related to #3040

Refactoring of popup logic/calling to be able to reuse it as commit list.

* Removed reset flag

Removed reset flag cause it doesn't belong to this PR (will be readded later)

Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
Co-authored-by: Lars Hvam <larshp@hotmail.com>
This was referenced Oct 26, 2020
@sandraros
Copy link
Contributor

sandraros commented Aug 10, 2022

Some people asked where the commit can be selected, maybe this can be useful to comment here with a screenshot. Answer valid as of 1.116.0. Select the repository, click Settings, select the Commit and then Pull:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
3 participants