original_docstring: Compare all sql in two git tags to find new or changed files.
docstring: Compare all sql in two git tags to find new or changed files.
docstring_tokens: Compare all sql in two git tags to find new or changed files .
code: def compare_two_tags(git_repo, git_tag1, git_tag2):
      """Compare all sql in two git tags to find new or changed files."""
      df1 = read_tag_to_dataframe(git_repo, git_tag1)
      df2 = read_tag_to_dataframe(git_repo, git_tag2)
      # Get 2 columns from each df.
      df1part = df1.loc[:, ['full_path',
                            'dir_path',
                            'file_name',
                            'file_content_hash']]
      df2part = df2.loc[:, ['full_path',
                            'dir_path',
                            'file_name',
                            'file_content_hash']]
      # Get list of unchanged files based on exact hash match.
      df2_unchanged = pd.merge(df2part,
                               df1part,
                               how='inner',
                               left_on=['file_content_hash'],
                               right_on=['file_content_hash'])
      df2_unchanged.columns = ['full_path',
                               'dir_path',
                               'file_name',
                               'file_content_hash',
                               'full_path_y',
                               'dir_path_y',
                               'file_name_y']
      df2_unchanged = df2_unchanged.drop(columns=['full_path_y'])
      df2_unchanged = df2_unchanged.drop(columns=['dir_path_y'])
      df2_unchanged = df2_unchanged.drop(columns=['file_name_y'])
      # Get list of new files only.
      # Left join on file_name.
      df2_new = pd.merge(df2part, df1part, how='left', on='file_name')
      # Only return rows where they did not exist in git_tag1.
      df2_new = df2_new.loc[df2_new.notna()['file_content_hash_y'] == 0]
      # Rename the columns after join and drop file_content_hash_y column.
      df2_new = df2_new.drop(columns=['full_path_y'])
      df2_new = df2_new.drop(columns=['dir_path_y'])
      df2_new = df2_new.drop(columns=['file_content_hash_y'])
      df2_new.columns = ['full_path',
                         'dir_path',
                         'file_name',
                         'file_content_hash']
      # Finally make sure does not exist in the files unchanged list
      df2_new = pd.merge(df2_new,
                         df2_unchanged,
                         how='left',
                         left_on=['file_content_hash'],
                         right_on=['file_content_hash'])
      df2_new = df2_new.loc[df2_new.notna()['file_name_y'] == 0]
      df2_new = df2_new.drop(columns=['file_name_y'])
      df2_new = df2_new.drop(columns=['full_path_y'])
      df2_new = df2_new.drop(columns=['dir_path_y'])
      df2_new.columns = ['full_path',
                         'dir_path',
                         'file_name',
                         'file_content_hash']
      # Get list of files changed only by removing unchanged and new files.
      # Exclude unchanged files first.
      df2_changed = pd.merge(df2part,
                             df2_unchanged,
                             how='left',
                             left_on=['file_content_hash'],
                             right_on=['file_content_hash'])
      df2_changed = df2_changed.loc[df2_changed.notna()['file_name_y'] == 0]
      df2_changed = df2_changed.drop(columns=['full_path_y'])
      df2_changed = df2_changed.drop(columns=['dir_path_y'])
      df2_changed = df2_changed.drop(columns=['file_name_y'])
      df2_changed.columns = ['full_path',
                             'dir_path',
                             'file_name',
                             'file_content_hash']
      # Exclude new files.
      df2_changed = pd.merge(df2_changed,
                             df2_new,
                             how='left',
                             left_on=['file_content_hash'],
                             right_on=['file_content_hash'])
      df2_changed = df2_changed.loc[df2_changed.notna()['file_name_y'] == 0]
      df2_changed = df2_changed.drop(columns=['full_path_y'])
      df2_changed = df2_changed.drop(columns=['dir_path_y'])
      df2_changed = df2_changed.drop(columns=['file_name_y'])
      df2_changed.columns = ['full_path',
                             'dir_path',
                             'file_name',
                             'file_content_hash']
      # Join back to the original df2.
      df2_changed['change_type'] = "modified"
      df2_new['change_type'] = "new"
      # Combine dataframe of new and modified files
      df2_diff = df2_new.append(df2_changed, ignore_index=True)
      df2_diff_all = pd.merge(df2_diff, df2, how='inner')
  
      df2_diff_all = df2_diff_all.drop(columns=['file_content'])
      df2_diff_all = df2_diff_all.drop(columns=['file_content_hash'])
      df2_diff_all = df2_diff_all.drop(columns=['file_size'])
      df2_diff_all = df2_diff_all.drop(columns=['git_tag'])
      df2_diff_all['git_tag1'] = git_tag1
      df2_diff_all['git_tag2'] = git_tag2
      return df2_diff_all
code_tokens: def compare_two_tags ( git_repo , git_tag1 , git_tag2 ) : df1 = read_tag_to_dataframe ( git_repo , git_tag1 ) df2 = read_tag_to_dataframe ( git_repo , git_tag2 ) df1part = df1 . loc [ : , [ 'full_path' , 'dir_path' , 'file_name' , 'file_content_hash' ] ] df2part = df2 . loc [ : , [ 'full_path' , 'dir_path' , 'file_name' , 'file_content_hash' ] ] df2_unchanged = pd . merge ( df2part , df1part , how = 'inner' , left_on = [ 'file_content_hash' ] , right_on = [ 'file_content_hash' ] ) df2_unchanged . columns = [ 'full_path' , 'dir_path' , 'file_name' , 'file_content_hash' , 'full_path_y' , 'dir_path_y' , 'file_name_y' ] df2_unchanged = df2_unchanged . drop ( columns = [ 'full_path_y' ] ) df2_unchanged = df2_unchanged . drop ( columns = [ 'dir_path_y' ] ) df2_unchanged = df2_unchanged . drop ( columns = [ 'file_name_y' ] ) df2_new = pd . merge ( df2part , df1part , how = 'left' , on = 'file_name' ) df2_new = df2_new . loc [ df2_new . notna ( ) [ 'file_content_hash_y' ] == 0 ] df2_new = df2_new . drop ( columns = [ 'full_path_y' ] ) df2_new = df2_new . drop ( columns = [ 'dir_path_y' ] ) df2_new = df2_new . drop ( columns = [ 'file_content_hash_y' ] ) df2_new . columns = [ 'full_path' , 'dir_path' , 'file_name' , 'file_content_hash' ] df2_new = pd . merge ( df2_new , df2_unchanged , how = 'left' , left_on = [ 'file_content_hash' ] , right_on = [ 'file_content_hash' ] ) df2_new = df2_new . loc [ df2_new . notna ( ) [ 'file_name_y' ] == 0 ] df2_new = df2_new . drop ( columns = [ 'file_name_y' ] ) df2_new = df2_new . drop ( columns = [ 'full_path_y' ] ) df2_new = df2_new . drop ( columns = [ 'dir_path_y' ] ) df2_new . columns = [ 'full_path' , 'dir_path' , 'file_name' , 'file_content_hash' ] df2_changed = pd . merge ( df2part , df2_unchanged , how = 'left' , left_on = [ 'file_content_hash' ] , right_on = [ 'file_content_hash' ] ) df2_changed = df2_changed . loc [ df2_changed . notna ( ) [ 'file_name_y' ] == 0 ] df2_changed = df2_changed . drop ( columns = [ 'full_path_y' ] ) df2_changed = df2_changed . drop ( columns = [ 'dir_path_y' ] ) df2_changed = df2_changed . drop ( columns = [ 'file_name_y' ] ) df2_changed . columns = [ 'full_path' , 'dir_path' , 'file_name' , 'file_content_hash' ] df2_changed = pd . merge ( df2_changed , df2_new , how = 'left' , left_on = [ 'file_content_hash' ] , right_on = [ 'file_content_hash' ] ) df2_changed = df2_changed . loc [ df2_changed . notna ( ) [ 'file_name_y' ] == 0 ] df2_changed = df2_changed . drop ( columns = [ 'full_path_y' ] ) df2_changed = df2_changed . drop ( columns = [ 'dir_path_y' ] ) df2_changed = df2_changed . drop ( columns = [ 'file_name_y' ] ) df2_changed . columns = [ 'full_path' , 'dir_path' , 'file_name' , 'file_content_hash' ] df2_changed [ 'change_type' ] = "modified" df2_new [ 'change_type' ] = "new" df2_diff = df2_new . append ( df2_changed , ignore_index = True ) df2_diff_all = pd . merge ( df2_diff , df2 , how = 'inner' ) df2_diff_all = df2_diff_all . drop ( columns = [ 'file_content' ] ) df2_diff_all = df2_diff_all . drop ( columns = [ 'file_content_hash' ] ) df2_diff_all = df2_diff_all . drop ( columns = [ 'file_size' ] ) df2_diff_all = df2_diff_all . drop ( columns = [ 'git_tag' ] ) df2_diff_all [ 'git_tag1' ] = git_tag1 df2_diff_all [ 'git_tag2' ] = git_tag2 return df2_diff_all
short_docstring: Compare all sql in two git tags to find new or changed files.
short_docstring_tokens: Compare all sql in two git tags to find new or changed files .
comment: """Compare all sql in two git tags to find new or changed files."""$SEP$# Get 2 columns from each df.$SEP$# Get list of unchanged files based on exact hash match.$SEP$# Get list of new files only.$SEP$# Left join on file_name.$SEP$# Only return rows where they did not exist in git_tag1.$SEP$# Rename the columns after join and drop file_content_hash_y column.$SEP$# Finally make sure does not exist in the files unchanged list$SEP$# Get list of files changed only by removing unchanged and new files.$SEP$# Exclude unchanged files first.$SEP$# Exclude new files.$SEP$# Join back to the original df2.$SEP$# Combine dataframe of new and modified files