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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a utility to locate the root directory #622

Merged
merged 3 commits into from Nov 1, 2019
Merged

Conversation

pepicrft
Copy link
Contributor

@pepicrft pepicrft commented Nov 1, 2019

Short description 馃摑

This PR adds a utility that given a directory, it traverses up the directories hierarchy to find the root of the project. It's considered the root of the project a directory that contains a Tuist/ directory, or where the git repository is defined.

The Tuist/ directory will contain the project description helpers, and in the future, some other global files that are accessible by any project.

Note: There are so many changes in the imports because I ran swiftformat.

@pepicrft pepicrft requested a review from a team November 1, 2019 13:18
@pepicrft pepicrft self-assigned this Nov 1, 2019
@github-actions
Copy link
Contributor

github-actions bot commented Nov 1, 2019

@pepibumur your pull request is missing a changelog!

Copy link
Collaborator

@kwridan kwridan left a comment

Choose a reason for hiding this comment

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

Nice 馃憤

There's an extra layer of caching that could be done but that could be a future optimisation if needed.

e.g.

  • A
    • Tuist
    • B
      • C
      • D
      • E

Asking from C will traverse the file tree till A and cache:
"/A/B/C": "/A"

Asking from D, the cache doesn't have any entries for it, so will traverse again and update the cache
"/A/B/C": "/A"
"/A/B/D": "/A"

Seeing we've traversed via /A/B/ already, the cache could include that information to save a few lookups

Again this could be an enhancement later if needed 馃檪

Sources/TuistSupport/Utils/FileHandler.swift Outdated Show resolved Hide resolved
Sources/TuistSupport/Utils/FileHandler.swift Outdated Show resolved Hide resolved
@pepicrft pepicrft merged commit f0af7be into master Nov 1, 2019
@pepicrft pepicrft deleted the root-directory-locator branch November 1, 2019 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants