aormsby / Fork-Sync-With-Upstream-action

An action to automatically update your fork with new commits from the upstream repo
MIT License
254 stars 69 forks source link

has_new_commits returns true always #64

Open sawanverma opened 1 year ago

sawanverma commented 1 year ago

Even if the target branch is up to date with the upstream repo, the has_new_commits always returns true. I wanted to run another step but this issue is blocking. Can you please suggest?

aormsby commented 1 year ago

What version are you running?

sawanverma commented 1 year ago

aormsby/Fork-Sync-With-Upstream-action@v3.4.

My configuration looks like following

steps:

REQUIRED step

# Step 1: run a standard checkout action, provided by github
- name: Checkout target repo
  uses: actions/checkout@v2
  with:
    ref: stage
    # REQUIRED if your upstream repo is private (see wiki)
    persist-credentials: false

fatal: could not read Username for 'https://github.com/': No such device or address

The complete logs is as following

Sync upstream changes ----> 28s Run aormsby/Fork-Sync-With-Upstream-action@v3.4 with: target_sync_branch: stage target_repo_token: upstream_sync_branch: master upstream_sync_repo: my_upstream_repo upstream_repo_access_token: test_mode: false git_log_format_args: --pretty=oneline git_config_user: GH Action - Upstream Sync git_config_email: action@github.com git_config_pull_rebase: false host_domain: github.com shallow_since: 1 month ago /usr/bin/sh /home/runner/work/_actions/aormsby/Fork-Sync-With-Upstream-action/v3.4/entry/config_and_run.sh Running ACTION...

Setting git config from input vars. (Skips config for all inputs set to 'null'.) SUCCESS

Checking out target branch 'stage' for sync. Already on 'stage' Your branch is up to date with 'origin/stage'. Target branch checked out SUCCESS

Setting upstream repo to 'my_upstream_repo'. SUCCESS

Checking for new commits on upstream branch.

fatal: could not read Username for 'https://github.com/': No such device or address

No previous sync found from upstream repo. Syncing entire commit history.

Syncing new commits... Nothing new to pack. From https://github.com/my_upstream_repo

Pushing synced data to target branch. Everything up-to-date SUCCESS

Resetting git config to previous settings. Reset Complete

Action Complete New Commits Found-------> 0s Run echo "New commits were found to sync." echo "New commits were found to sync." shell: /usr/bin/bash -e {0} New commits were found to sync.

My question is since as per above, it says Everything up-to-date, then why its finding new commit?

What I am missing here? Can you please let me know? Thanks in advance for all the help.

aormsby commented 1 year ago

The output syntax was updated in #57. I wonder if maybe the syntax in the actions.yml file needs to be updated also. Not sure, will have to look over the docs.

kurorinchan commented 2 months ago

I believe the problem is this line https://github.com/aormsby/Fork-Sync-With-Upstream-action/blob/1090e365224fc834e7e1de521c417ded2d6fcb53/run/get_updates.sh#L28

It should be -z instead of -n. If the hash (commit) is included, the name of the branch is output hence non-empty. Otherwise it's empty (and the error message goes to stderr).

So the work around would be to invert the boolean in your action for the current version. Remove the inversion once fixed.