Skip to content

Conversation

@ZPascal
Copy link
Collaborator

@ZPascal ZPascal commented May 6, 2022

Add --force-with-lease functionality from the following PR on a smoother way.

TODO's:

@ZPascal ZPascal requested a review from ad-m May 6, 2022 17:30
@ZPascal ZPascal self-assigned this May 6, 2022
@ZPascal ZPascal added the enhancement New feature or request label May 6, 2022
@ZPascal ZPascal removed the request for review from ad-m May 7, 2022 18:59
@ZPascal ZPascal force-pushed the add-force-with-lease-support branch from 05c9b06 to 85e4b8d Compare May 8, 2022 15:29
@ZPascal ZPascal requested a review from ad-m May 8, 2022 15:31
@ZPascal
Copy link
Collaborator Author

ZPascal commented May 22, 2022

Hi @ad-m & @jackton1, the PR is ready for a review :) Could you please review it?

@jackton1
Copy link
Contributor

@ZPascal Sorry for the delay, Sure I'll take a look

@ZPascal ZPascal force-pushed the add-force-with-lease-support branch from d48f8dc to 5229503 Compare June 10, 2022 18:17
@ZPascal
Copy link
Collaborator Author

ZPascal commented Jun 11, 2022

Is @jackton1 the PR from your side ready to merge?

required: false
force_with_lease:
description: 'Determines if force-with-lease push is used'
required: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a default here

Suggested change
required: false
required: false
default: false

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but then it's not consistent with the rest.

set -e

INPUT_FORCE=${INPUT_FORCE:-false}
INPUT_FORCE_WITH_LEASE=${INPUT_FORCE_WITH_LEASE:-false}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can reduce redundant default declarations and provide them in the actions.yml

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.


git push "${remote_repo}" HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION $_TAGS;
if ${INPUT_FORCE_WITH_LEASE}; then
git push --follow-tags $_FORCE_OPTION $_TAGS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to use a different set of options and arguments here? It seems like overkill to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, yes. Otherwise, it's not working. The combination of the checkout configuration and the corresponding light and different push command solves the problems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide some more information like logs it might be helpful to know and document the subtleties of using either option.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked in my records and could not find any more logs. I will repeat the test tonight and provide the corresponding logs.

Copy link
Contributor

@jackton1 jackton1 Jun 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still curious as to why we need to couple the behaviour with the checkout action as opposed to using the specified branch and also pushing without the remote_repo which includes the user-defined token ??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackton1 I fired through a corresponding test setup and ran the two actions with two different versions each.
Version 1 ⇾ Current setup of the push command with force-with-lease support.
Version 2 ⇾ Modified version with rebuilt push command.

You can clearly see in version 1 that the command is not executed and rejected.

Push to branch refs/pull/11/merge
Pushing to https://github.com/ZPascal/grafana_dashboard_templater.git
POST git-receive-pack (8[9](https://github.com/ZPascal/grafana_dashboard_templater/runs/6923390058?check_suite_focus=true#step:4:10)9 bytes)
To https://github.com/ZPascal/grafana_dashboard_templater.git
 ! [remote rejected] HEAD -> refs/pull/11/merge (deny updating a hidden ref)
error: failed to push some refs to 'https://github.com/ZPascal/grafana_dashboard_templater.git'
Error: Invalid exit code: 1
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ad-m/github-push-action/cfc[10](https://github.com/ZPascal/grafana_dashboard_templater/runs/6923390058?check_suite_focus=true#step:4:11)a6161cb45fdaa7cb39dfb870e1ac7c32d3d/start.js:29:21)
    at ChildProcess.emit (events.js:3[14](https://github.com/ZPascal/grafana_dashboard_templater/runs/6923390058?check_suite_focus=true#step:4:15):20)
    at maybeClose (internal/child_process.js:1022:[16](https://github.com/ZPascal/grafana_dashboard_templater/runs/6923390058?check_suite_focus=true#step:4:17))
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) {
  code: 1
}

In the modified version 2 everything works as expected.

If you have further questions or want to see log messages, please let me know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jackton1, do you have any further questions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope looks good. Thanks for the explanation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackton1 Could you please approve it or should I modify more code lines?

start.sh Outdated
git config --local --add safe.directory ${INPUT_DIRECTORY}

git push "${remote_repo}" HEAD:${INPUT_BRANCH} --follow-tags $_FORCE_OPTION $_TAGS;
#if ${INPUT_FORCE_WITH_LEASE}; then
Copy link
Contributor

@jackton1 jackton1 Jun 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the commented lines ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll uncomment the lines/ revert the tested modifications and squash the changes together.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Perfect

@ZPascal ZPascal force-pushed the add-force-with-lease-support branch from 81c3a1e to c894fcf Compare June 25, 2022 21:12
* Update the documentation
@ZPascal ZPascal force-pushed the add-force-with-lease-support branch from d624b04 to e5f70b0 Compare June 25, 2022 21:31
@ZPascal ZPascal merged commit 6195df7 into ad-m:master Jun 25, 2022
@ZPascal ZPascal deleted the add-force-with-lease-support branch June 25, 2022 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants