Skip to content

Commit

Permalink
Merge pull request #900 from launchableinc/track-shallow-clone
Browse files Browse the repository at this point in the history
Track shallow clone
  • Loading branch information
ono-max authored Aug 6, 2024
2 parents bf48e52 + 235df89 commit 33176a6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions launchable/commands/record/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,32 @@ def commit(ctx, source: str, executable: bool, max_days: int, scrub_pii: bool, i
)
client.print_exception_and_recover(e)

cwd = os.path.abspath(source)
try:
exec_jar(os.path.abspath(source), max_days, ctx.obj, is_collect_message)
is_shallow = subprocess.check_output(
['git', 'rev-parse', '--is-shallow-repository'],
stderr=subprocess.DEVNULL,
cwd=cwd,
universal_newlines=True).strip()
if is_shallow == "true":
tracking_client.send_event(
event_name=Tracking.Event.SHALLOW_CLONE
)
except Exception as e:
if os.getenv(REPORT_ERROR_KEY):
raise e
else:
print(e)
try:
exec_jar(cwd, max_days, ctx.obj, is_collect_message)
except Exception as e:
if os.getenv(REPORT_ERROR_KEY):
raise e
else:
click.echo(click.style(
"Can't get commit history from `{}`. Do you run command root of git-controlled directory? "
"Couldn't get commit history from `{}`. Do you run command root of git-controlled directory? "
"If not, please set a directory use by --source option."
.format(os.path.abspath(source)),
.format(cwd),
fg='yellow'),
err=True)
print(e)
Expand Down
2 changes: 1 addition & 1 deletion launchable/utils/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Tracking:
# General events
class Event(Enum):
SHALLOW_CLONE = 'shallow_clone' # this event is an example
SHALLOW_CLONE = 'SHALLOW_CLONE' # this event is an example

# Error events
class ErrorEvent(Enum):
Expand Down

0 comments on commit 33176a6

Please sign in to comment.