Skip to content

Github API - Diverging branch causes initial commit to be lost if branch already exists #5463

@MattiasAng

Description

@MattiasAng

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

We've been seeing intermittent issues with some file changes not actually being applied and I finally had some time to look through it further than having to do manual checks and commits.

If base branch and head branch diverges and force is enabled (which is required with API), the initial commit will be lost during the reset and subsequent push.

I'm gonna take a guess straight away that this might come down to;

  1. Branch is shown as diverging and reset to base.
  2. Commit is done using API.
  3. Pull from remote fails as its not able to fast-forward.

Haven't had time to investigate this more but will try to do so during the week if time allows.

(I implemented the initial Github API feature so I'm probably responsible for introducing this bug but haven't been used enough to be bothered by it until now).

Expected Behavior

Commits should be kept when resetting diverging branch.

Steps To Reproduce

  1. Given a simple configuration of a Github SCM with commitUsingApi: true and a single YAML target:

    name: "Bump helm charts versions"
    
    pipelineid: "example"
    
    scms:
      default:
        kind: github
        spec:
          ...
          hideCredit: true
          commitUsingApi: true
          force: true
    
    targets:
      HelmValuesImageTag:
        name: "Update"
        kind: yaml
        scmid: default
        spec:
          file: "values.yaml"
          key: "$.imageTag"
          value: "{{ requiredEnv .version }}"
  2. Run updatecli to create the initial commit.

  3. Make any change in the base branch.

  4. Run updatecli again. The initial commit will be missing and a new one has not been pushed.

  5. If ran once more, it will work as expected.

Environment

- OS: Same issue on Ubuntu 22.04 (Github Actions) and locally on Mac
- updatecli: v0.101.0

Pipeline Graph

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingscm-githubSCM of type GiHhub

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions