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

Add on_git_branch command to detect whether a specific git branch is checked out #702

Merged
merged 26 commits into from Nov 29, 2020

Conversation

brianrodri
Copy link
Contributor

@brianrodri brianrodri commented Oct 30, 2020

When working on GitHub projects, I've found it helpful to have env variables set-up when I'm inside a specific branch. For example, sometimes I want to change the merge-base my editor uses to display signifiers. I can accomplish this with the new command like so:

if on_git_branch child_changes; then
  export MERGE_BASE_BRANCH=parent_changes
fi

To detect movement between branches, the .git/HEAD file is watched with watch_file. This is only done when a branch name is specified, otherwise no calls to watch_file are made.

@brianrodri brianrodri changed the title Introduce on_branch to stdlib Add GitHub branch condition "on_branch" to stdlib Nov 4, 2020
@brianrodri brianrodri changed the title Add GitHub branch condition "on_branch" to stdlib Add GitHub branch predicate "on_branch" to stdlib Nov 4, 2020
@brianrodri brianrodri changed the title Add GitHub branch predicate "on_branch" to stdlib Add on_branch to detect whether a GitHub branch is currently checked out Nov 4, 2020
@brianrodri brianrodri changed the title Add on_branch to detect whether a GitHub branch is currently checked out Add on_git_branch to detect whether a GitHub branch is currently checked out Nov 4, 2020
@brianrodri brianrodri changed the title Add on_git_branch to detect whether a GitHub branch is currently checked out Add on_git_branch command to detect whether a specific GitHub branch is checked out Nov 4, 2020
@brianrodri brianrodri changed the title Add on_git_branch command to detect whether a specific GitHub branch is checked out Add on_git_branch command to detect whether a specific git branch is checked out Nov 4, 2020
Copy link
Member

@zimbatm zimbatm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good!

Can you also document the function in man/direnv-stdlib.1.md ?

stdlib.sh Outdated Show resolved Hide resolved
stdlib.sh Outdated Show resolved Hide resolved
stdlib.sh Outdated Show resolved Hide resolved
Copy link
Contributor Author

@brianrodri brianrodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed comments + added entry to man/direnv-stdlib.1.md, PTAL!

stdlib.sh Outdated Show resolved Hide resolved
stdlib.sh Outdated Show resolved Hide resolved
stdlib.sh Outdated Show resolved Hide resolved
@zimbatm
Copy link
Member

zimbatm commented Nov 28, 2020

It looks like the branch is ready?

@brianrodri
Copy link
Contributor Author

brianrodri commented Nov 29, 2020

Yup, I'm happy with it if you are!

@zimbatm zimbatm merged commit b7f1875 into direnv:master Nov 29, 2020
@zimbatm
Copy link
Member

zimbatm commented Nov 29, 2020

thanks!

@brianrodri brianrodri deleted the on_branch branch November 29, 2020 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants