gitcoinco / gitcoinco/web

Bin bash

Open
#11,065 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.8k
Forks
776
PR merge metrics
No merged PRs in 30d

Description

User Story:
As a
I want to
So that

Acceptance Criteria
GIVEN
WHEN
THEN

Product & Design Links:

Tech Details:

Open Questions:

Notes/Assumptions:
#!/bin/bash

Purpose: Create a new feature branch and push it to the remote repository

Print messages with a timestamp

print_message() {
echo ""
echo "$(date +"%Y-%m-%d %H:%M:%S") - $1"
}

Display help message

show_help() {
echo "Usage: $0 <feature_branch_name>"
echo ""
echo "Options:"
echo " -h, --help Display this help message."
exit 0
}

Handle errors

handle_error() {
print_message "Error: $1"
exit 1
}

Parse command-line arguments

while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) show_help ;;
*) FEATURE_BRANCH_NAME=$1; shift ;;
esac
done

Ensure a branch name is provided

if [[ -z "$FEATURE_BRANCH_NAME" ]]; then
handle_error "No feature branch name provided. Usage: $0 <feature_branch_name>"
fi

Check if git is installed

if ! command -v git &> /dev/null; then
handle_error "Git is not installed. Please install Git."
fi

Ensure inside a git repository

if ! git rev-parse --is-inside-work-tree &> /dev/null; then
handle_error "Not inside a valid git repository."
fi

Check if the branch exists locally

if git show-ref --verify --quiet refs/heads/"$FEATURE_BRANCH_NAME"; then
handle_error "Branch '$FEATURE_BRANCH_NAME' already exists locally."
fi

Clear local cache of remote branches

print_message "Fetching latest remote branches to clear any cached data."
git fetch origin --prune || handle_error "Failed to fetch remote branches."

Check if the branch exists remotely

if git ls-remote --heads origin "$FEATURE_BRANCH_NAME" | grep "$FEATURE_BRANCH_NAME" &> /dev/null; then
handle_error "Branch '$FEATURE_BRANCH_NAME' already exists on the remote."
fi

Create the new feature branch

print_message "Creating new feature branch: $FEATURE_BRANCH_NAME"
git checkout -b "$FEATURE_BRANCH_NAME" || handle_error "Failed to create feature branch: $FEATURE_BRANCH_NAME"

Push the new branch to the remote and set upstream tracking

print_message "Pushing feature branch '$FEATURE_BRANCH_NAME' to the remote repository"
git push -u origin "$FEATURE_BRANCH_NAME" || handle_error "Failed to push feature branch to the remote."

Show the current branch and status

print_message "Branch '$FEATURE_BRANCH_NAME' created and pushed successfully."
print_message "Current branch: $(git branch --show-current)"
git status || handle_error "Failed to show git status."

print_message "Script completed successfully."IMG_20241007_194517_519.jpg

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue body contains an inline Bash script for creating and pushing a Git feature branch, but names no repository file, entry point, or expected change. First clarify where the script belongs and what behavior is required; completion criteria are not provided, so no implementation or test can be identified from the issue alone.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, git
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.