feat!(git-config): use full name for git configuration (#141)
							parent
							
								
									aef9b3b116
								
							
						
					
					
						commit
						ac54966f5e
					
				@ -1,43 +0,0 @@
 | 
				
			|||||||
import { describe, expect, it } from "bun:test";
 | 
					 | 
				
			||||||
import {
 | 
					 | 
				
			||||||
  executeScriptInContainer,
 | 
					 | 
				
			||||||
  runTerraformApply,
 | 
					 | 
				
			||||||
  runTerraformInit,
 | 
					 | 
				
			||||||
  testRequiredVariables,
 | 
					 | 
				
			||||||
} from "../test";
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
describe("git-config", async () => {
 | 
					 | 
				
			||||||
  await runTerraformInit(import.meta.dir);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  testRequiredVariables(import.meta.dir, {
 | 
					 | 
				
			||||||
    agent_id: "foo",
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  it("fails without git", async () => {
 | 
					 | 
				
			||||||
    const state = await runTerraformApply(import.meta.dir, {
 | 
					 | 
				
			||||||
      agent_id: "foo",
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    const output = await executeScriptInContainer(state, "alpine");
 | 
					 | 
				
			||||||
    expect(output.exitCode).toBe(1);
 | 
					 | 
				
			||||||
    expect(output.stdout).toEqual([
 | 
					 | 
				
			||||||
      "\u001B[0;1mChecking git-config!",
 | 
					 | 
				
			||||||
      "Git is not installed!",
 | 
					 | 
				
			||||||
    ]);
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  it("runs with git", async () => {
 | 
					 | 
				
			||||||
    const state = await runTerraformApply(import.meta.dir, {
 | 
					 | 
				
			||||||
      agent_id: "foo",
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    const output = await executeScriptInContainer(state, "alpine/git");
 | 
					 | 
				
			||||||
    expect(output.exitCode).toBe(0);
 | 
					 | 
				
			||||||
    expect(output.stdout).toEqual([
 | 
					 | 
				
			||||||
      "\u001B[0;1mChecking git-config!",
 | 
					 | 
				
			||||||
      "git-config: No user.email found, setting to ",
 | 
					 | 
				
			||||||
      "git-config: No user.name found, setting to default",
 | 
					 | 
				
			||||||
      "",
 | 
					 | 
				
			||||||
      "\u001B[0;1mgit-config: using email: ",
 | 
					 | 
				
			||||||
      "\u001B[0;1mgit-config: using username: default",
 | 
					 | 
				
			||||||
    ]);
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
@ -1,24 +0,0 @@
 | 
				
			|||||||
#!/usr/bin/env sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
BOLD='\033[0;1m'
 | 
					 | 
				
			||||||
printf "$${BOLD}Checking git-config!\n"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Check if git is installed
 | 
					 | 
				
			||||||
command -v git > /dev/null 2>&1 || {
 | 
					 | 
				
			||||||
  echo "Git is not installed!"
 | 
					 | 
				
			||||||
  exit 1
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Set git username and email if missing
 | 
					 | 
				
			||||||
if [ -z $(git config --get user.email) ]; then
 | 
					 | 
				
			||||||
  printf "git-config: No user.email found, setting to ${GIT_EMAIL}\n"
 | 
					 | 
				
			||||||
  git config --global user.email "${GIT_EMAIL}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if [ -z $(git config --get user.name) ]; then
 | 
					 | 
				
			||||||
  printf "git-config: No user.name found, setting to ${GIT_USERNAME}\n"
 | 
					 | 
				
			||||||
  git config --global user.name "${GIT_USERNAME}"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
printf "\n$${BOLD}git-config: using email: $(git config --get user.email)\n"
 | 
					 | 
				
			||||||
printf "$${BOLD}git-config: using username: $(git config --get user.name)\n\n"
 | 
					 | 
				
			||||||
					Loading…
					
					
				
		Reference in New Issue