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

branch-solution fails with Ubuntu runners #229

Closed
nigelcharman opened this issue Aug 22, 2022 · 3 comments · Fixed by #407
Closed

branch-solution fails with Ubuntu runners #229

nigelcharman opened this issue Aug 22, 2022 · 3 comments · Fixed by #407

Comments

@nigelcharman
Copy link
Contributor

Running with an ubuntu-latest runner, the branch-solution action fails with the message:

Error: failed: Error: Cannot determine HEAD from remote: ...

@nigelcharman
Copy link
Contributor Author

On Windows runners, the results of git remote show log are returned as a single line, whereas on Ubuntu the results are returned as multiple lines. This causes the map() function to return an array with multiple elements in, which then fails the check for a single element.

nigelcharman added a commit to Assurity-Cloud/powerplatform-actions that referenced this issue Aug 22, 2022
nigelcharman added a commit to Assurity-Cloud/powerplatform-actions that referenced this issue Aug 22, 2022
@nigelcharman
Copy link
Contributor Author

We added these logging statements to debug it:

  const remotes = yield git.run(["remote", "show", "origin"]);
  logger.info(`remotes: ${remotes}`);
  const head = remotes.map((line) => {
    logger.info(`line: ${line}`);
    const branch = line.match(/HEAD branch:\s*(\S+)/);
    if (branch && branch.length >= 2) {
      logger.info(`branch: ${branch}`);
      return branch[1];
    }
  });
  logger.info(`head: ${head}`);
  if (!head || head.length < 1 || head.length > 1 || !head[0]) {
    throw new Error(`Cannot determine HEAD from remote: ${repoUrl}`);
  }

Here's the output from the different runners:

windows-latest Runner

  remotes: * remote origin
    Fetch URL: https://github.com/hud-govt-nz/ppm
    Push  URL: https://github.com/hud-govt-nz/ppm
    HEAD branch: main
    Remote branches:
      AzureDevOps-20220821-2245                                  tracked
      AzureDevOps-20220822-0131                                  tracked
      build2                                                     tracked
      capgemini_port                                             tracked
      dependabot/nuget/PPMUnitTestProject/Newtonsoft.Json-13.0.1 tracked
      install-git-lfs                                            tracked
      main                                                       tracked
      specflow                                                   tracked
      specflow-powerapps-bindings                                tracked
  
 line: * remote origin
    Fetch URL: https://github.com/hud-govt-nz/ppm
    Push  URL: https://github.com/hud-govt-nz/ppm
    HEAD branch: main
    Remote branches:
      AzureDevOps-20220821-2245                                  tracked
      AzureDevOps-20220822-0131                                  tracked
      build2                                                     tracked
      capgemini_port                                             tracked
      dependabot/nuget/PPMUnitTestProject/Newtonsoft.Json-13.0.1 tracked
      install-git-lfs                                            tracked
      main                                                       tracked
      specflow                                                   tracked
      specflow-powerapps-bindings                                tracked
  
  branch: HEAD branch: main,main
  head: main

ubuntu-latest Runner

  remotes: * remote origin,  Fetch URL: https://github.com/hud-govt-nz/ppm,  Push  URL: https://github.com/hud-govt-nz/ppm,  HEAD branch: main,  Remote branches:,    AzureDevOps-20220821-2245                                  tracked,    AzureDevOps-20220822-0131                                  tracked,    AzureDevOps-20220822-0153                                  tracked,    build2                                                     tracked,    capgemini_port                                             tracked,    dependabot/nuget/PPMUnitTestProject/Newtonsoft.Json-13.0.1 tracked,    install-git-lfs                                            tracked,    main                                                       tracked,    specflow                                                   tracked,    specflow-powerapps-bindings                                tracked,
  
  line: * remote origin
  line:   Fetch URL: https://github.com/hud-govt-nz/ppm
  line:   Push  URL: https://github.com/hud-govt-nz/ppm
  line:   HEAD branch: main
  branch: HEAD branch: main,main
  line:   Remote branches:
  line:     AzureDevOps-20220821-2245                                  tracked
  line:     AzureDevOps-20220822-0131                                  tracked
  line:     AzureDevOps-20220822-0153                                  tracked
  line:     build2                                                     tracked
  line:     capgemini_port                                             tracked
  line:     dependabot/nuget/PPMUnitTestProject/Newtonsoft.Json-13.0.1 tracked
  line:     install-git-lfs                                            tracked
  line:     main                                                       tracked
  line:     specflow                                                   tracked
  line:     specflow-powerapps-bindings                                tracked
  line: 
  head: ,,,main,,,,,,,,,,,,
  Error: failed: Error: Cannot determine HEAD from remote: https://github.com/hud-govt-nz/ppm

@audunsolemdal
Copy link

This issue is still occurring for me on ubuntu-latest with the "current" @v0 tag, commit cf1fafb

Error: failed: Error: Cannot determine HEAD from remote: xxx/yyyy

tehcrashxor added a commit that referenced this issue Jul 18, 2023
* Filter non-matching lines from git command (branch-solution)

* npm run update-dist

---------

Co-authored-by: Clemens Schlomka <clemens.schlomka@vibracoustic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants