Skip to content

[FEATURE] show error/warning in createDeltaPkg if source is missing commits already present on target branch #2052

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

Open
JoernBerkefeld opened this issue Feb 5, 2025 · 0 comments
Labels
e/DevOps EPIC enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story"
Milestone

Comments

@JoernBerkefeld
Copy link
Contributor

JoernBerkefeld commented Feb 5, 2025

in short, check if git log reveals that target branch should first get merged into source branch:
git log --oneline feature-branch..origin/main

something like this should do the trick:

const simpleGit = require('simple-git');
 
// Initialize simple-git
const git = simpleGit();
 
// Function to check if there are commits on `main` that are not in the feature branch
async function checkCommits() {
  try {
// Fetch the latest changes specifically for the remote 'main' branch
     await git.fetch('origin', 'main');
 
    // Run the `git log` command to check for commits on `main` not in the feature branch
    const log = await git.log(['feature-branch..origin/main']);
 
    // If there are commits, advise the user to merge `main` into the feature branch
    if (log.total > 0) {
      console.log("There are commits in the 'main' branch that are not in your feature branch.");
      console.log("Please merge 'main' into your feature branch first to avoid unintended merge outcomes.");
    } else {
      console.log("Your feature branch is up to date with 'main'. You can proceed with merging.");
    }
  } catch (err) {
    console.error('Error checking commits:', err);
  }
}
 
// Run the function
checkCommits();

not sure if fetching is always wanted though.

@JoernBerkefeld JoernBerkefeld added e/DevOps EPIC enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story" labels Feb 5, 2025
@JoernBerkefeld JoernBerkefeld modified the milestones: 7.7.0, 7.8.0 Feb 5, 2025
@JoernBerkefeld JoernBerkefeld modified the milestones: 7.8.0, Minor 1 Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e/DevOps EPIC enhancement New feature or request; requires increasing the minor version of mcdev. Jira issue-type "Story"
Projects
None yet
Development

No branches or pull requests

1 participant