Skip to content

fix(git_push): replace force with force_with_lease - #5

Merged
rootCircle merged 2 commits into
rootCircle:mainfrom
Sidharth-Singh10:force_lease
Jun 23, 2025
Merged

fix(git_push): replace force with force_with_lease#5
rootCircle merged 2 commits into
rootCircle:mainfrom
Sidharth-Singh10:force_lease

Conversation

@Sidharth-Singh10

Copy link
Copy Markdown
Contributor

Replaced the basic force flag with force-with-lease functionality to prevent accidental overwrites of remote changes.
Added force_with_lease: bool and optional force_with_lease_ref: Option<String> field

force_with_lease_ref: allows specifying exact commit hash the remote should be at

@codecov-commenter

codecov-commenter commented Jun 9, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 76 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
src/events/git_push.rs0.00%73 Missing ⚠️
src/workflows/default/action/ta09_pull_push.rs0.00%3 Missing ⚠️
Files with missing linesCoverage Δ
src/workflows/default/action/ta09_pull_push.rs0.00% <0.00%> (ø)
src/events/git_push.rs0.00% <0.00%> (ø)

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rootCircle

Copy link
Copy Markdown
Owner

Related #4

@rootCircle
rootCircle requested a review from CopilotJune 11, 2025 17:57

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the git push functionality to replace the basic force push flag with a safer force‐with‐lease approach, reducing the risk of accidentally overwriting remote changes. Key changes include:

  • Removing the old force push mechanism and introducing the force_with_lease flag and an optional force_with_lease_ref field.
  • Adding new validation logic and refspec construction for handling force‐with‐lease pushes.
  • Updating error messages to reflect the revised push strategy.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

FileDescription
src/workflows/default/action/ta09_pull_push.rsUpdated push configuration to use force_with_lease instead of force.
src/events/git_push.rsReplaced the force flag with force_with_lease and added new validation/refspec functions for safe push behavior.
Comments suppressed due to low confidence (1)

src/events/git_push.rs:271

  • Consider adding a comment clarifying the purpose and format of the refspec string that uses curly braces to denote the expected OID for force‐with‐lease. This will help future maintainers understand the string construction and its relation to git push semantics.
Ok(format("+{}^{{{}}}", base_refspec, expected_ref))

Comment threadsrc/events/git_push.rs
Comment threadsrc/events/git_push.rs Outdated
Comment on lines 139 to 148
pub fn set_force_with_lease(&mut self, force_with_lease: bool) -> &mut Self {
self.force_with_lease = force_with_lease;
self
}

#[allow(dead_code)]
pub fn set_force_with_lease_ref(&mut self, ref_name: Option<String>) -> &mut Self {
self.force_with_lease_ref = ref_name;
self
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nitpicky thing, but whenever with a method, you pass the ref and return the value itself (not the ref), it generally comes under builder pattern. (different from getter/setter)

for that method prefix their names with with_ instead of set_

Comment threadsrc/events/git_push.rs Outdated
pub pre_check_rules: Vec<Box<dyn Rule + Send + Sync>>,
pub force: bool,
pub force_with_lease: bool,
pub force_with_lease_ref: Option<String>,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why do we actually need this from user POV? Trying to think about the usecase here for force_with_lease_ref

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It just came up when I was searching for force_with_lease. Thought it might be useful in some scenario.
So i added in the PR to be reviewed 😅

Comment threadsrc/events/git_push.rs Outdated
Comment threadsrc/events/git_push.rs Outdated

@rootCirclerootCircle left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM 👍

@rootCircle
rootCircle merged commit e543f19 into rootCircle:mainJun 23, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Sidharth-Singh10@codecov-commenter@rootCircle